From: Vassil Nikolov on 15 Oct 2009 00:00 On 14 Oct 2009 14:13:33 -0400, Alan Bawden <alan(a)shaggy.csail.mit.edu> wrote about the origin and standardization of DEFSTRUCT. Thank you very much. * * * I don't know what the cost to implementors would be to change the respective DEFSTRUCT implementations to fully capture the lexical environment at the point of definition (rather than the point of inclusion). In any case, this is a matter of low severity (as I think has already been said in this thread), and moreover it is easy for the user to achieve such behavior in any implementation by simply rewriting (let ((x 0)) (defstruct foo (a x))) along the lines of (let ((x 0)) (progn (defun #1=#:initval () x) (defstruct foo (a (#1#))))) so then e.g. the following tests pass: (progn (defstruct (bar (:include foo))) (let ((x 1)) (declare (ignorable x)) (defstruct (baz (:include foo)))) (assert (zerop (bar-a (make-bar)))) (assert (zerop (let ((x 1)) (declare (ignorable x)) (bar-a (make-bar))))) (assert (zerop (baz-a (make-baz)))) (assert (zerop (let ((x 1)) (declare (ignorable x)) (baz-a (make-baz)))))) (it doesn't look too difficult to produce a macro that does the above rewriting in the general case). ---Vassil. -- "Even when the muse is posting on Usenet, Alexander Sergeevich?"
From: Madhu on 15 Oct 2009 00:27 * Vassil Nikolov <snztyy1z4q8.fsf(a)luna.vassil.nikolov.name> : Wrote on Thu, 15 Oct 2009 00:00:15 -0400: | I don't know what the cost to implementors would be to change the | respective DEFSTRUCT implementations to fully capture the lexical | environment at the point of definition (rather than the point of | inclusion). In any case, this is a matter of low severity (as I | think has already been said in this thread), It is also of limited utility if you observe how the Common Lisp Specification for defstruct promises that the file compiler will recognize an earlier defstruct for Inclusion via INCLUDE only the earlier defstruct appeared as a toplevel form. | and moreover it is easy for the user to achieve such behavior in any | implementation by simply rewriting [snip] This will work for at most 1 level of inclusion. In the face of the file compiler operation, unless you change the wording in parts of the standard, you cannot expect to do this portably unless the included defstruct is at a toplevel form --- without a lexical environment. i.e. (in your example) you cannot expect (let ((SOMEENV)) (defstruct CALF (:include baz))) to be portably compiled. -- Madhu
From: Vassil Nikolov on 15 Oct 2009 00:52 On Thu, 15 Oct 2009 09:57:24 +0530, Madhu <enometh(a)meer.net> said: > ... > This will work for at most 1 level of inclusion. I am too curious about this particular remark. Are you saying that the example below will not work, or are you saying something else? (let ((x 0)) (progn (defun #1=#:initval () x) (defstruct foo (a (#1#))))) (progn (let ((x 1)) (declare (ignorable x)) (defstruct (baz (:include foo)))) (let ((x 1)) (declare (ignorable x)) (defstruct (quux (:include baz)))) (assert (zerop (baz-a (make-baz)))) (assert (zerop (let ((x 1)) (declare (ignorable x)) (baz-a (make-baz))))) (assert (zerop (quux-a (make-quux)))) (assert (zerop (let ((x 1)) (declare (ignorable x)) (quux-a (make-quux)))))) ---Vassil. -- "Even when the muse is posting on Usenet, Alexander Sergeevich?"
From: Madhu on 15 Oct 2009 01:00 * Vassil Nikolov <snzeip5z2bn.fsf(a)luna.vassil.nikolov.name> : Wrote on Thu, 15 Oct 2009 00:52:12 -0400: | On Thu, 15 Oct 2009 09:57:24 +0530, Madhu <enometh(a)meer.net> said: |> ... |> This will work for at most 1 level of inclusion. | | I am too curious about this particular remark. Are you saying that | the example below will not work, or are you saying something else? Sorry, looking at what I said, I believe I made a mistake in saying it is required to work at all if put in a file and compiled. I believe the Specification promises that the file compiler will recognize an earlier defstruct for Inclusion via INCLUDE only if the earlier defstruct appeared as a toplevel form. In your example the included defstruct is not defined as a top level form -- Madhu
From: Tamas K Papp on 15 Oct 2009 03:41
On Thu, 15 Oct 2009 00:28:19 +0200, Pascal Costanza wrote: > Heck, they got prog2 wrong. ;) This issue being discussed here is much How is prog2 wrong? (Or if this is a joke, sorry, I am not getting it). Tamas |