Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 4621 days ago | link | parent

Yes, this isn't currently legal:

  def (foo) :case a :case b  # second case is ignored
Is this what you meant?

---

I think I wasn't clear about my meaning. Consider the following definition:

  def (foo 'a b)
    ..
This can mean two things:

a) Selective-quoting: foo takes two args, the first isn't eval'd.

b) Pattern-matching: that definition of foo is dispatched to if the first arg is a.

So I wasn't sure which to use. Since I posted this I ended up using backquotes for pattern matching, so for case b) you'd end up saying:

  def (foo `a b)
    ..


1 point by rocketnia 4619 days ago | link

"Since I posted this I ended up using backquotes for pattern matching"

I agree with Pauan. This is reasonable. ^_^ Well, beware of corner cases like trying to match literal uses of the symbol 'unquote.

-----

1 point by akkartik 4619 days ago | link

Wart knows knows no symbol unquote, only a literal comma :)

-----

1 point by Pauan 4620 days ago | link

"Is this what you meant?"

Yes.

---

"Since I posted this I ended up using backquotes for pattern matching"

That sounds reasonable. It's what I would have done in the past.

-----