def (a = b)
..
Is this a function with parameter "a" assigned to value "b" by default? If so, what is the function's name? # basic type-based dispatch
mac (lhs <- rhs) :case list?.lhs
..
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)
..))-----
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)-----
Thanks Pauan for the clarifying comments!
-----