Arc Forumnew | comments | leaders | submitlogin
2 points by evanrmurphy 5081 days ago | link | parent

Let's build on this with one of akkartik's earlier proposals [1] to allow for specifying default values:

> b) Quote destructured args to distinguish them from optional args.

  (a b '(c d)) ; destructured
  (a b (c 3) (d)) ; optional args
By making all arguments optional, we no longer need parentheses around the final argument in that list. This plus dot ssyntax allows us to rewrite the example as follows:

  (a b c.3 d)
For another example, take waterhouse's accumulate [2], which can now be rewritten:

  (def accumulate (over starting.nil taking.car 
                   folding-with.cons next.cdr until.no)
      ... )
Update: To be honest, however much I liked this idea in theory, I'm not sure I like how it turned out in these examples. :-/

Another Update: I think it's because I like implicit pairs so much [3] that I actually prefer akkartik's incumbent syntax for optional args:

  (def accumulate (over ? starting nil  taking car  
                          folding-with cons 
                          next cdr  until no)
    ... )
---

[1] http://arclanguage.org/item?id=12575

[2] http://arclanguage.org/item?id=12946

[3] http://arclanguage.org/item?id=13032



2 points by akkartik 5081 days ago | link

Interesting train of thought.

Another idea is perhaps to use '=' as ssyntax for optional args.

  (def accumulate(over starting=nil taking=car folding-with=cons next=cdr until=no)
    ..)

-----