Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Keyword arguments in R7RS

Name: Anonymous 2010-03-18 6:27

Things are getting spicy.
[quote]
Neil Van Dyke
To get the keyword arguments discussion started, I'll provide a quick,
loosely-defined strawperson...
* Keywords look like ":foo", "foo:", or "#:foo", depending on your dialect.
* The main use of keywords is to name "keyword arguments" in procedure
applications and syntax uses, such as for optional arguments or for clarity.
* "lambda" is extended to permit keyword arguments to be defined, each
of which argument may have a default value.  The argument is optional
iff a default value was defined.
* The various syntax definition forms should permit syntax transformers
to be keyword-aware as well.
* Example:
(define f (lambda (a b c (:foo 42) :bar)  foo))
(f 1 2 3 :foo 4 :bar 5) ==> 4
(f 1 2 3 :bar 5) ==> 42
(f 1 2 3) =error=> :bar keyword argument required
(f 1 2 3 :foo 4 :bar 5 :zoo 6) =error=> unrecognized keyword :zoo
* Note: If keywords are first-class values, and you want to pass a
keyword as an argument in an application in a position in which it might
be parsed as a keyword, you cannot put  a keyword literal into the
application syntax directly.
* I probably wouldn't have keyword arguments in WG2, but their
implementation in WG2 would likely impose requirements on WG1.
--
[/quote]

Working Group 1 thread:
https://groups.google.com/group/scheme-reports-wg1/browse_frm/thread/3c0c5a48a520f32d
or
Working Group 2 thread:
https://groups.google.com/group/scheme-reports-wg2/browse_frm/thread/4f4b2a9a0eb86450

...what do the resident clispers in prague think? Should they exist in the core language or should we have a supplementary (i.e. "defun" in all its glory) macro for WG2 Scheme?

Name: Anonymous 2010-03-18 6:47

As a CLer, I think keyword arguments are very useful(among the other lambdalist arguments such as &optional and&rest(well, you can write it using dot notation too)) in writing highly-parametrized functions and reducing boilerplate code.

If CL didn't have them, they would be trivial to implement with macros and compiler-macros - the other needed component being a destructuring-bind, but that can also be written portably.

I'm not sure how hard would be to add support for them as a library in Scheme, but probably wouldn't be terribly hard.

There is one major advantage to having the language include native support for them: people will use them everywhere, which shapes your language and implementation as well as how other people write code. If they are not included in the language specification, then less people will use them in actual code.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List