This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: conditional bindings
- From: Per Bothner <per at bothner dot com>
- To: kawa at sourceware dot org
- Date: Thu, 11 Dec 2014 21:07:19 -0800
- Subject: Re: conditional bindings
- Authentication-results: sourceware.org; auth=none
- References: <54868D3A dot 10605 at bothner dot com> <8FDA27DC-2AC0-442E-879B-390760EAC000 at theptrgroup dot com> <5487BD04 dot 4080709 at bothner dot com> <1A9D21C9-3897-47BD-AB86-60D249A9CB8D at theptrgroup dot com> <54891FCF dot 2000608 at bothner dot com> <0890BFFE-8180-4F6D-9F1A-9E93F0E9C9BA at theptrgroup dot com> <5489E441 dot 3030502 at bothner dot com> <E8E1CF30-33BD-4BFE-9412-176558B932E5 at theptrgroup dot com>
On 12/11/2014 02:43 PM, Jamison Hope wrote:
On Dec 11, 2014, at 1:36 PM, Per Bothner <per@bothner.com> wrote:
(define (f #!key (x 0) (y 0)) (cons x y))
(let ((y: 7) (x: 1)) (f y: 2 x: 3))
=> (3 . 2)
...
With --r7rs it returns (0 . 0).
It is semi-correct: if x: and y: are plain symbols (rather than keywords)
then the x and y parameters both default to 0.
However, f should probably complain about excess/unused arguments.
That will hopefully happen with the apply-convention rewrite, which
will include faster and more robust keyword argument-passing.
Actually, I can't figure out a way
to pass a keyword argument with --r7rs, although it didn't prevent
me from defining the function.
Kawa supports the Guile/Racket syntax:
(f #:y 2 #:x 3) ==> (3 . 2)
I edited the Keywords section in doc/kawa.texi to better document
this syntax. (It was only entioned in the "Hash-prefixed forms" section.)
--
--Per Bothner
per@bothner.com http://per.bothner.com/