And then this is a case where my code doesn't actually use multiple arguments to = for accidental reasons, but this is what it would look like:
(def nrev (xs)
(let u nil
(whilet head xs
(= xs cdr.xs
cdr.head u ;I actually use scdr here
u head))
u))
Hmm... come to think of it, I guess it could be done, perhaps better, with parallel assignment. You have to be careful, though. The "cdr.xs" that is set to "u" should be the cdr of the original xs.
(def nrev (xs)
(let u nil
(while xs ;no whilet
(p= xs cdr.xs
cdr.xs u
u xs))
u))
And then there are about 20 cases in which I assign multiple things with = and it wouldn't matter whether it was parallel or not. And there's a case in which I had to be a bit careful about the ordering to make sequential = work.
I almost never think about using parallel assignment, at least not explicitly. (But, hmm, it seems it would be useful for destructive operations on AVL trees, or any data structure. But it must be defined carefully.) I frequently use it in a loop, but it appears as a tail-recursive call; in fact, the example that is the subject of this thread could be done in that style:
(def fib (n)
(xloop (n n a 0 b 1)
(if (is n 0)
a
(next (- n 1) b (+ a b)))))
I do believe that the language should provide both a parallel = and a sequential =. I'm not entirely sure which one should be afforded "official =" status. For the moment, portable code could use "=*" or maybe "=s" for sequential and "p=" or something for parallel assignment (it definitely has to be no more than two characters).
"I do believe that the language should provide both a parallel = and a sequential =. I'm not entirely sure which one should be afforded "official =" status. For the moment, portable code could use "=" or maybe "=s" for sequential and "p=" or something for parallel assignment (it definitely has to be no more than two characters)."
That sounds reasonable. In fact, then = could just be an alias... something like this:
(assign = =p)
And then if you would prefer = to be sequential, you could do this:
(assign = =s)
This would of course clobber other code that expects = to be parallel, but that should be handled by a module/namespace system, so I'm not worried about that.
Side note: maybe we should avoid giving them names that look like emoticons...