Arc Forumnew | comments | leaders | submitlogin
2 points by rntz 5500 days ago | link | parent

I very much expect the current behavior. Can't really say why, it just seems natural to me that a list as a case means "pattern-match", not "any one of these". Also it would break compatibility with pg's arc. Adding a new macro, say, 'mcase ("multi-case") or 'orcase, would be totally fine though.


1 point by akkartik 5500 days ago | link

Or add a sym to the case itself.

    (case x (in 1 3 5) 'odd ..)
Harder to implement, though.

-----

1 point by aw 5500 days ago | link

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 5500 days ago | link

How about allowing cases to be functions?

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

-----

1 point by twilightsentry 5500 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.

-----

1 point by aw 5500 days ago | link

'casein occurs to me, reminiscent of 'in

-----