Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4404 days ago | link | parent

"No clue what's going on here, unfortunately. Would you mind walking me through it?"

When wart sees a symbol that is punctuation, it treats it as an infix operator, so that (a + b) and (a = b) work, etc.

As for :case, that's basically equivalent to "extend" in Arc. In other words, in Arc you write this:

  (extend foo ... (bar ...))
But in wart you would write this:

  def foo ... :case (bar ...)
And this topic is about Common Lisp (defun foo ...) vs. Scheme (define (foo ...))

---

So, if you put it all together, that means this:

  def (a = b)
    ..
Is equivalent to this in Arc:

  (def = (a b)
    ..)
---

And this:

  mac (lhs <- rhs) :case list?.lhs
    ..
Is equivalent to this in Arc:

  (mac <- (lhs rhs)
    (when (list? lhs)
      ..))


3 points by evanrmurphy 4404 days ago | link

Thanks. So when the function name is grouped with its parameters in definition (as it is in scheme), and infix is permitted, no longer does the function name have to come before its parameters.

I would have to get used to not always seeing the function name first, but I like the symmetry this produces between definition and call.

Added: So when wart got infix (http://arclanguage.org/item?id=16775), Kartik gave this example for defining your own infix ops:

  def (<>) (a b)
    (~iso a b)
"<>" had to be in parens so that wart's infixey reader wouldn't try to swap it with "def". Now thanks to scheme-style grouping of the function name with its params, this definition can be written:

  def (a <> b)
    (~iso a b)

-----

2 points by akkartik 4404 days ago | link

Exactly. Sorry, I think you're missing http://arclanguage.org/item?id=16826. In brief, = is now equality and <- is now assignment. And since both are composed of operator chars, (def (a <- b) ..) is transparently read as (def (<- a b) ..), which now maps directly to the scheme-like declaration syntax, etc., etc.

Thanks Pauan for the clarifying comments!

-----