guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird stuff with define*


From: Maciej Stachowiak
Subject: Re: Weird stuff with define*
Date: 18 Sep 2000 16:42:29 -0700
User-agent: Gnus/5.0802 (Gnus v5.8.2) Emacs/20.4

"Jorgen 'forcer' Schaefer" <address@hidden> writes:

> Hi there!
> I just noticed a few funny things with define* from (ice-9
> optargs):
> 
> guile> (define* (foo #:optional bar #:key baz)
>   (cons bar baz))
> guile> (foo 'bar #:baz 'baz)
> (bar . baz)
> guile> (foo #:baz 'baz 'bar)
> (#:baz . #<undefined>)

Hmm, it's bad to leak the undefined value, but the default value for a
keyword, if you don't specify one, is the undefined value. Perhaps the
default for the default value should be #f or something.
 
> guile> (define* (foo #:key bar #:rest baz)
>   (list bar baz))
> guile> (foo #:bar 'bar 'the 'rest)
> (bar (#:bar bar the rest))

This is on purpose, as other similar APIs include keyword arguments in
the rest arg. If you didn't, it gets confusing thinking about the
right way to parse them out. Perhaps some other clear, consistent
behavior could be designed.

 - Maciej


reply via email to

[Prev in Thread] Current Thread [Next in Thread]