[plt-scheme] Re: Cloning objects?

From: Laurent (laurent.orseau at gmail.com)
Date: Wed Dec 9 05:38:48 EST 2009

On Tue, Dec 8, 2009 at 17:32, Laurent <laurent.orseau at gmail.com> wrote:

>
> And, BTW, despite the use of `define-syntax-rule', when omitting the
> `source' argument in the `init-field-clone' definition,
> the form still works but becomes non-hygienic! Now I have to completely
> rewire my brain again...
>
>
More exactly:
`source' can be omitted from the arguments:

(define-syntax-rule (init-field-clone [var val] ...)
>   (begin
>     (init [source #f])
>     (init-field [var (if source (get-field var source) val)] ...)))
>

it seems that `source' is inaccessible, but then it cannot be used as a
field anymore:

> (define c1%
>   (class object%
>     (init-field-clone [source "z"])
>     (super-new)
>     ))
> error: class: duplicate declared external init name in: source
>

how can this be if the macro is hygienic?
Well, of course, if it were completely internalized, I could not instantiate
c1% with `new'...
Does that means that it is `init' or `init-field' that are non-hygienic?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20091209/8e57bb90/attachment.html>

Posted on the users mailing list.