[plt-scheme] class init

From: Robby Findler (robby at cs.uchicago.edu)
Date: Fri Apr 14 09:21:13 EDT 2006

Something like this?

(class canvas%
   (init (my-callback #f))
   (unless (or (not my-callback) (procedure-arity-includes? my- 
callback 2))
     (error 'bad-callback "more info here, presumably")))

Robby

On Apr 14, 2006, at 8:06 AM, Ivanyi Peter wrote:

> Robby Findler <robby at cs.uchicago.edu> írta:
>
>>> I create a subclass and add a new init value to the class.
>>> How can I check the value of the supplied init value
> during the
>>> instantiation of the class? (For example the given value
>>> satisfies
>>> certain minimal requirements.)
>>
>> So, for now, you'll have to manually
>> put in a check.
>
> How can I do that? (Maybe I am not understanding something
> here.)
> For example if I have a code like below, when this class is
> instantiated
>   (new my-canvas (my-callback (lambda (w e) #f)))
> I would like to check that the given callback function has two
> arguments. I would like to check that "in the class" and not
> before I
> instantiate a class.
>
> (define my-canvas%
>     (class canvas%
>       (init (my-callback #f))
>       ...
>       (define (on-event event)
>         ...
>         (if my-callback
>           (my-callback this event))
>       )
>
>       (super-new ...)
>    )
> )
>
> Thanks,
>
> Peter Ivanyi
>
>
> ______________________________________________________________________ 
> _________
> Új Építésű ingatlanok, bankfüggetlen hitelajánlatok,  
> kedvezményes konstrukciók:
> http://ad.adverticum.net/b/cl,1,6022,97912,159457/click.prm
>
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>



Posted on the users mailing list.