Nota Poin wrote on 11/08/2015 08:41 PM:
What I want is implicit keyword names for arguments with defaults. So
instead of:
(define (foo #:bar? (bar? #f) #:foo (foo 42) #:some-variable-name
(some-variable-name 3)) ...)
I'd like a variation on this. Since I (and lots of existing Racket
code) still use positional optional arguments sometimes, and since I'm
not sure I *always* want arguments (regardless of whether optional) to
have implicit keywords... I'd like simply a shorthand meaning "keyword
argument derived from argument variable name".
I haven't yet thought of a good backward-compatible syntax for this, but
two non-ideal ideas:
(define (bunny #(x) #(y) #(care-bears 1)) BODY ...)
(define (bunny #f x #f y #f (care-bears 1)) BODY ...)
Example uses:
(bunny :x 1 :y 2)
(bunny :x 3 :y 4 :care-bears 1000)
Note that, unlike some languages, I *don't* want `x` and `y` to be
optionally positional -- only keyworded. If I wanted positional
arguments, they'd be *only* positional, and not optionally keyworded.
Example:
(define (pony x y #(unicorn? #true)) BODY ...)
(pony 5 6)
(pony 5 6 :unicorn? #false)
(pony :x 7 8) ;=ERROR=> pony does not expect keyword argument `:x`
(pony 5 6 #false) ;=ERROR=> pony expects 2 positional arguments, not 3
Neil V.
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.