Arc Forumnew | comments | leaders | submitlogin
3 points by Pauan 4433 days ago | link | parent

"But dispatching on the number of parameters can't be that hard, right?"

Racket has this built-in (scroll down to "case-lambda"):

http://docs.racket-lang.org/reference/lambda.html?q=case-lam...)

It's not hard to write a macro in Arc/Nu that uses Racket's case-lambda, and in fact I had a semi-working version, but I gave that up when I started work on Nulan.

Unlike Arc, Nulan doesn't have optional args, so you have to use arity overloading:

  $def foo
    X Y -> X + Y       # 2 argument version
    X   -> (foo X 10)  # 1 argument version: default for Y is 10
Though I suppose it shouldn't be too hard to write a pattern matcher that supports optional args... something like this:

  $def foo
    X (opt Y 10) -> X + Y
In this case, "opt" is an object that has a %pattern-match type, which means users can write their own pattern matchers, unlike in Arc where it's all hardcoded.