[plt-scheme] A macro for declaring class properties, a question

From: Jens Axel Soegaard (jensaxel at soegaard.net)
Date: Thu Oct 18 13:20:49 EDT 2007

Grant Rettke skrev:
> On 10/18/07, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>> No. See macro-stepper.
> 
> I got an error "class*: duplicate declared external field name in:
> super-secret-field-name"

That's due to the following code from class-internal.ss, which
uses (syntax-e id) to convert the identifiers to symbols, thus
deleting any marks.

In short, normally it would have worked, but not in this case.
It only if the you expand to plays fair.


(let ([check-dup
         (lambda (what l)
           (let ([ht (make-hash-table)])
             (for-each (lambda (id)
                         (when (hash-table-get ht (syntax-e id) #f)
                           (bad (format
                                 "duplicate declared external ~a name"
                                  what) id))
                         (hash-table-put! ht (syntax-e id) #t))
                         l)))])
   ;; method names
   (check-dup "method" (map cdr
                            (append publics overrides augrides
                                    pubments overments augments
                                    public-finals override-finals
                                    augment-finals)))
   ;; inits
   (check-dup "init" (map norm-init/field-eid (append normal-inits)))
   ;; fields
   (check-dup "field" (map norm-init/field-eid
                          (append normal-plain-fields
                                  normal-plain-init-fields))))

Grant, as an experiment (I haven't tried) change check-dup
to

(let ([check-dup
         (lambda (what l)
           (void))]
   ...)

and see what happens with your example.

-- 
Jens Axel Søgaard




Posted on the users mailing list.