[plt-scheme] first-class methods

From: Dave Herman (dherman at ccs.neu.edu)
Date: Sun Nov 28 14:02:39 EST 2004

Someone may have explained this to me once, but I can't remember. Why 
can't public methods be passed as first-class values inside the class 
definition?

   (define my-class%
     (class object%
       (public purple? foo)
       (define (purple? x)
         (eq? x 'purple))
       (define (foo ls)
         (filter purple? ls))
       (super-new)))

*** class: misuse of method (not in application) in: purple?

(If you don't make purple? public, this works.) It looks to me like you 
could make this work by having method declarations expand both to their 
current implementation and to an identifier macro that expands purple? 
in argument position to (lambda args (apply purple? args)). Why wouldn't 
this work?

Thanks,
Dave


Posted on the users mailing list.