Restrictions of :initfrom?
Posted: Sun Jul 10, 2011 4:09 am
Or, rather, how could I use a value that needs to be computed rather than a constant? All examples I find are too simplistic in that they show how to use :initfrom when initializing slot of a class with a literal value such as number or string. However I need to use an object. Something along these lines:
Since it doesn't compile it sends me to this page: http://www.lispworks.com/documentation/ ... /07_ab.htm for clarification, and I can't understand what is the error I'm making. The commented struct above shows what I would like to use hypothetically, but, I'd need it to be a class.
EDIT: Sorry, never mind it, silly typo
It should've been :initform instead.
Code: Select all
(defstruct
(as3-fqname
(:print-function
(lambda (struct stream depth)
(declare (ignore depth))
(format stream "~a:~a"
(as3-fqname-package struct)
(as3-fqname-name struct)))))
(package "" :type string)
(name "" :type string))
;; (defstruct (amf-object
;; (:print-function
;; (lambda (struct stream depth)
;; (declare (ignore depth))
;; (format stream "[~a object]"
;; (amf-object-class struct)))))
;; (class (make-as3-fqname :as3-name "Object")
;; :type as3-fqname)
;; (properties (make-hash-table :test 'equal)))
;; (make-amf-object :class (make-as3-fqname :package "foo" :name "Bar"))
(defclass amf-object ()
((constructor
:initarg :constructor ;; if I uncomment the below I'll get error
;; :initfrom (make-as3-fqname :as3-name "Object")
:type as3-fqname)
(properties
;; :initfrom (make-hash-table :test 'equal)
:type hash-table)))
EDIT: Sorry, never mind it, silly typo
![Smile :)](./images/smilies/icon_e_smile.gif)