[plt-scheme] keyword arguments, take 2
On Jun 14, Carl Eastlund wrote:
> I like the proposal for a lot of reasons. One thing discussed
> around the office here at NU that it doesn't address is keywords
> with more/less than one argument. For instance, keywords can
> conceptually be used alone (i.e. as flags, as in (open "/dev/random"
> #:read-only)), or have multiple arguments (Ryan's example was
> (connect #:tcp "localhost" 80) -- connect takes a keyword specifying
> a protocol, and the keyword takes however many arguments the
> protocol needs). I don't have an immediate counterproposal for how
> to include these, but I think they can be useful features,
> especially the zero-argument "flag" use.
Some quick comments about this:
1. The `#:read-only' example is not a good one. That's a case where
it would have been better to use a `mode' argument with a symbol
value.
2. I'm not sure that `flag' arguments (in the sense of the current
"kw.ss") are useful. They were hacked on by Sam's request, but
never really used by him. I don't know of any other uses of these
flags, so I think that that it wouldn't be a problem to give up
that feature.
3. Finally, for the multi-values bound to different names, you can
want the same without keywords:
(define (connect mode (host port)) ...)
(connect 'tcp ("localhost" 80))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!