[plt-scheme] A macro for declaring class properties, a question
On 10/18/07, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> Hygiene means create names to avoid binding conflicts. So in this case,
> imagine that each use of (property name) would actually introduce
> super-secret-name1, super-secret-name2, etc. See macro stepper.
In the case of Noel's code, then:
(define-syntax property
(syntax-rules ()
[(_ name)
(begin (field super-secret-field-name)
(define/public name
(case-lambda
[() super-secret-field-name]
[(value) (set! super-secret-field-name value)])))]))
Hygiene would avoid name clashes if all of the properties are
generated within that macro: think (property x y z) versus (property
x) (property y) (property z). Otherwise super-secret-field-name would
get generated 3 times? I think this is the case as I just tried out
the latter and got name clashes.