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-19 13:05

>>21
Consider the following wrapper:

(define (increase-counter s)
  (display "Increasing counter ") (display s) (newline))

(define (wrap-with-counter f default-name)
  (lambda (#:name (name default-name) . rest)
    (increase-counter name)
    (apply f rest)))


This works fine until I try to combine it with the following totally unrelated procedure, which may be in a different library.

(define (create-object #:name (name "default object name"))
  (list 'object name))


I cannot solve this without changing one of them. I cannot import one of the keywords with a different name like I can with an SRFI 39 parameter. The two keywords are the same even though they obviously shouldn't be, just because they happen to use the same name.

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