Arc Forumnew | comments | leaders | submitlogin
1 point by aw 5469 days ago | link | parent

That's a clever idea, I think I probably would use a macro that let me check a value against a series of expressions (perhaps using some form of currying). I don't think I'd call it "case" though :-)


1 point by akkartik 5469 days ago | link

How about allowing cases to be functions?

  (case x
    [in _ '(1 3 5)] 'odd
    ..)

-----

1 point by twilightsentry 5469 days ago | link

I've got a macro like that, which I call 'test. The problem with combining that and 'case is distinguishing functions and constants before the cases are eval'ed.

  (mac testlet (var expr . args)
    (letf ex (args)
           (if cdr.args
               `(if (,car.args ,var) ,cadr.args
                    ,(args cddr.args))
               car.xs)
      `(let ,var ,expr ,(ex args))))
Anyway, I'll probably just define 'casein as aw and rntz suggested.

-----