NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
your macro (Score:1)
I consulted the manual and came up with this which doesn't work because the original x isn't getting updated anymore.
(defmacro ++ (x)
"Increment the value of symbol X, returning the new value"
(let ((xt (make-symbol "quoted-x")))
`(let ((,xt (quote
(set
This fixes three bugs. x is evaluated only once. I'm getting a new variable QUOTED-X to store my temp stuff in and not letting it sneak out. I'm treating expression as quoted on the left side and executing it on the right. Um... I *hope* that's sufficient to remove the bugs.
Macros are stupidly hard.
Reply to This
Re:your macro (Score:2)
Oh, I didn't think of that! I was only thinking of passing in a symbol constant. But now I see what you mean. [emacswiki.org]
As to the general hardness of Lisp macros: I'm glad it's not just me that thinks that.
Maybe there's just some kind of magic syntax-highlighty thing in (e)lisp mode that will turn on all the happy macro easiness or something.
Emacs is a pathless land.
Re:your macro (Score:1)
As for making macros easier, I'm sure the Scheme folks have stuff on this. I'm a novice at this but I could guess that you might write something to check that each value is only used once. Something to do with data flows maybe.