This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: conditional bindings


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/


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