[plt-scheme] optional parameters?

From: troels knak-nielsen (troelskn at gmail.com)
Date: Sun Sep 16 17:46:50 EDT 2007

OK. I kind of had a suspicion, that Prometheus was exotic. I like it
very much though. I tried to read the manual on classes/objects, and
it was rather confusing for me. Prometheus OTOH makes immediate sense,
coming to Scheme from a javascript background.

I mailed Jorgen directly, and got the following reply (In case anybody
else wonders about the same)

--
troels

On 9/16/07, Jorgen Schaefer <forcer at forcix.cx> wrote:
> "troels knak-nielsen" <troelskn at gmail.com> writes:
>
> > Hi
> >
> > I'm using a port of prometheus, for plt-scheme (
> > http://planet.plt-scheme.org/package-source/daedalus/prometheus.plt/1/0/doc.txt
> > ). It's working fine, but I have a method, which I would like to give
> > an optional argument. How can I make an argument optional, and how do
> > I specify a default value for
> > when it isn't supplied? Is it even possible, or should I use a
> > different strategy?
>
> This works in Prometheus the same way as with any other Scheme
> procedure:
>
> > (define-object test (*the-root-object*)
>     ((message self resend . optional-args)
>      optional-args))
> ; no values returned
> > (test 'message 1)
> '(1)
> > (test 'message 1 2)
> '(1 2)
> > (test 'message 1 2 3)
> '(1 2 3)


Posted on the users mailing list.