Marco Antoniotti's blog on Lisp and other interesting bits of programming.
20110107
NEW project on common-lisp.net
There is a NEW project on common-lisp.net. The new-op pages contain documentation and download instructions to get the code for the new operator in Common Lisp I described in a previous post.
(cheers)
@5thyear: I think that set-structure-constructor suggests that there is a unique structure constructor (after all, (structure-constructor 'foo) would return just one thing), and that it might suggest that it can make something be a constructor, which isn't the case—it's just informing the system that something is, in fact, a constructor. (setf (structure-constructor …) …) is even more suggestive than set-structure-constructor, I think.
Guys. The structure constructor hack is just a ... despicable kludge :)
Think of the following
(defstruct (foo (:constructor fooize) (:constructor build-foo (a &optional s d))) a s d)
Which constructor should NEW call? All in all, I think the only passable solution would be to dig down into an implementation and find out what the reader calls when it sees
#S(FOO :A 42 :S NIL :D T)
As for the naming, I have, but I did not export, the function to get the constructor from the internal data-base. The naming is intended to suggest that something is made known to the system (as YeshuaAaron pointed out). An alternative would be RECORD-STRUCTURE-CONSTRUCTOR.
I don't like the REGISTER-STRUCTURE-CONSTRUCTOR function and its syntax. Too long and too ugly.
ReplyDeleteAt a minimum, change it to SET-STRUCTURE-CONSTRUCTOR, or even
(setf (structure-constructor 'foo) #'make-structure)
@5thyear: I think that set-structure-constructor suggests that there is a unique structure constructor (after all, (structure-constructor 'foo) would return just one thing), and that it might suggest that it can make something be a constructor, which isn't the case—it's just informing the system that something is, in fact, a constructor. (setf (structure-constructor …) …) is even more suggestive than set-structure-constructor, I think.
ReplyDeleteGuys. The structure constructor hack is just a ... despicable kludge :)
ReplyDeleteThink of the following
(defstruct (foo (:constructor fooize) (:constructor build-foo (a &optional s d)))
a s d)
Which constructor should NEW call? All in all, I think the only passable solution would be to dig down into an implementation and find out what the reader calls when it sees
#S(FOO :A 42 :S NIL :D T)
As for the naming, I have, but I did not export, the function to get the constructor from the internal data-base. The naming is intended to suggest that something is made known to the system (as YeshuaAaron pointed out). An alternative would be RECORD-STRUCTURE-CONSTRUCTOR.