Arc Forumnew | comments | leaders | submitlogin
New in wart: param aliases
4 points by akkartik 2194 days ago | 2 comments
You can now[1] refer to a parameter by multiple names:

  def foo(a/b)
    (cons a b)

  (foo 3) ; => (3 . 3)
Why's this useful? It allows me to connect up params with different keyword args. For example, my old test has weird param names because I want to say things like ":valueof (+ 1 1) :should be 2":

  def test(msg valueof should expected)
    if (valueof should expected)
Now I can say instead:

  def test(msg expr/valueof pred/should expected)
    if (pred expr expected)

Racket supports keyword args[2], and it lets you name your keyword args separately, but you're forced to provide their name even if it's the same:

  > (define (foo #:a a) a)
  > (foo #:a 3)
Wart, on the other hand, only requires the name of the keyword when it's different from the param.



  $ git clone
  $ cd wart
  $ git checkout fd54da7e80
  $ wart

1 point by evanrmurphy 2193 days ago | link

Very interesting feature.

Does this mean that '/' is a disallowed character in wart symbols in general, or only in parameters?


2 points by akkartik 2192 days ago | link

Only in parameters. And even there you can start variables with a '/'. See for multi-ary division -- the $/ expands to something like /170.