This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Source for wiki NamedParametersCowan version 1

author

cowan

comment


    

ipnr

198.185.18.207

name

NamedParametersCowan

readonly

0

text

== Named Parameters ==

In this design, keywords are disjoint from symbols, but there is no special syntax for them: for each keyword, a variable is bound to the value of that keyword.  Keywords must be compared with `keyword=?` rather than with `eq?`.

== Syntax ==

`(lambda/keywords `''arg'' ... `(`''key''` `''value''`) `...`) ''body'' ...`)`  [syntax]

Returns a procedure whose body is ''body'' that accepts non-keyword arguments ''args'' and keyword arguments whose names are ''keys''.  ''Values'' specify the default value for the corresponding ''keys''.

Note that ''keys'' need not have any particular syntax such as beginning with or ending with a colon, but they may do so by convention.  As identifiers, keywords must be explicitly exported from modules.

`(define/keywords (`''name''` `''arg'' ... `(`''key''` `''value''`) `...`) ''body'' ...`)`  [syntax]

Defines a procedure named ''name'' with body `(lambda/keywords `''arg'' ... `(`''key''` `''value''`) `...`) `''body'' ...`)`

== Procedures ==

`(make-keyword `''symbol''`)`

Constructs and returns a keyword object whose name is ''symbol''.

`(keyword? `''obj''`)`

Returns `#t` if ''obj'' is a keyword object, and `#f` otherwise.

`(keyword=? `''kw1''` `''kw2''`)`

Returns `#t` if ''kw1'' and ''kw2'' are keywords with the same name, and `#f` if they have different names.  It is an error if ''kw1'' and ''kw2'' are not keyword objects.

== Rationale and implementation ==

See KeywordArgumentsArcfide.  The syntax keywords `define/keywords` and `lambda/keywords` here correspond to `define/optional` and `lambda/opt` there.

time

2010-09-28 04:11:02

version

1