Re: Simple symbols as keywords soo 08 May 2006 03:01 UTC

For examples, we can use simple symbols as keywords as follows:

((check-lambda (a
		b
		"opt" c
		"key" ((d dd) 30) e (f 40)
		. g)
   (list a b c d e f g))
 0 1 2 'dd 3 'f 6 'd 4 'dd 5)	=> unknown keysymbol d

((check-lambda (a
		b
		"opt" c
		"key" ((d dd) 30) e (f 40)
		"allow-other-keys"
		. g)
   (list a b c d e f g))
 0 1 2 'dd 3 'f 6 'd 4 'dd 5)	=> duplicate keysymbol dd

((check-lambda (a
		b
		"opt" c
		"key" ((d dd) 30) e (f 40)
		"allow-other-keys"
		"allow-duplicate-keys"
		. g)
   (list a b c d e f g))
 0 1 2 'dd 3 'f 6 'd 4 'dd 5)	=> (0 1 2 3 #f 6 (d 4 dd 5))

((check-lambda (a
		b
		"opt" c
		"key" ((d dd) 30) e (f 40)
		#t
		. g)
   (list a b c d e f g))
 0 1 2 'dd 3 'f 6 'd 4 'dd 5)	=> (0 1 2 3 #f 6 (d 4 dd 5))

The following is the specification:
(check-lambda  <formals> <body>)
(check-lambda* <formals> <body>)

<formals> -->
| (<required variable spec>* <fixed spec>* <named spec>* <option>)
| <variable>
| (<required variable spec>+ <fixed spec>* <named spec>* <option> .
<variable>)
| (<fixed spec>+ <named spec>* <option> . <variable>)
| (<named spec>+ <option> . <variable>)
| ("cat" . <variable>)
<required variable spec> --> <variable> | (<variable> <test>+)
<fixed spec> --> "opt" <fixed variable spec>*
<named spec> --> "key" <named variable spec>*
	       | "key" <named variable spec>+ <named option>
<fixed variable spec> --> <variable> | (<variable> <default value>
<test>*)
<named variable spec> --> <fixed variable spec>
			| ((<variable> <keyword name>))
			| ((<variable> <keyword name>) <default value>
<test>*)
<named option> --> #f | #t | <named option modifier>+
<named option modifier> --> "allow-other-keys"  | "allow-non-keys"
			  | "allow-duplicate-keys"
<option> --> "cat" | <empty>
<default value> --> <expression>
<test> --> <expression>
<keyword name> --> <identifier>

I can attach the implementation, if you want to take a look at it.

--
Joo ChurlSoo