This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: An optional arguments interface




Mikael Djurfeldt <mdj@nada.kth.se> wrote:
>Maciej Stachowiak <mstachow@mit.edu> writes:
>>     (lambda* (a b [c d] . e) '())
>
>This is neat, but to me it feels a bit un-schemey to introduce that
>kind of syntax.  It feels as if it's a new syntactic idea to demarcate
>a part of the parameter list like that.  (We don't want the Scheme
>syntax to evolve into something JAVA-like, do we? ;-)

It's been traditional in LISP dialects to mark optional arguments by
marking off part of the parameter list with some prefix, usually
&opt. I just have a slightly different way of marking them. Yes, it's
a new syntactic idea, but nothing other than procedure definitions and
the like needs a concept of optional values. Anyway, I hardly see how
treating some characters specially in a macro is "Java-like" - after
all, part of the fun of Scheme and Lisp in general is the ability to
extend the language.

>Personally I think I'd prefer to add some special form inside those
>"higher level" procedures which need optional arguments:
>
>(lambda (a b . args)
>  (letarg ((c <c-default>)
>	   (d)
>           e)
>    (if (bound? d)
>        ...)
>    ...))
>

I noticed after I posted my stuff that the guile-scsh module already
has a macro in this latter style (let-optional), but unfortunately,
guile-scsh is not very usable yet, and I also like the more compact
syntax of my macros; it seems more readable to me to have both normal
and optional args in one place. I can always change the token that
separates the optional arguments to something more traditional, like
&opt or #{some character}optional if people really object to the
brackets.

 - Maciej Stachowiak