Re:Why Lisp macros are cool, a Perl perspective (2005)
by B1FF_PSUVM on Monday December 16, 2019 @05:44PM
(#21808280)
Unpopular opinions, CLVII: Sturgeon's law applies to macros. Squared.
[ Parent
| on HN ]
Re:Why Lisp macros are cool, a Perl perspective (2005)
by RHSeeger on Tuesday December 17, 2019 @01:29AM
(#21811199)
Being able to write new control structures is something I miss in most languages. Lisp macros make it much easier to do that. Tcl uplevel and upvar are another way to approach it.
Re:Why Lisp macros are cool, a Perl perspective (2005)
by LessDmesg on Tuesday December 17, 2019 @01:48AM
(#21811274)
Curious: what kind of new control structures do you miss in other languages?
Re:Why Lisp macros are cool, a Perl perspective (2005)
by stevelosh on Tuesday December 17, 2019 @01:09PM
(#21816553)
This would save me literally thousands of lines of code at my day job:
(defmacro ?= (symbol-or-symbols expr)
(let* ((symbols (etypecase symbol-or-symbols
(cons symbol-or-symbols)
(symbol (list symbol-or-symbols))))
(tmps (loop :for s :in symbols :collect (gensym (symbol-name s))))
(err (gensym "ERROR")))
`(multiple-value-bind (,@tmps ,err) ,expr
(if (not (null ,err))
(return ,err)
(setf (values ,@symbols) (values ,@tmps))))))
Re:Why Lisp macros are cool, a Perl perspective (2005)
by RHSeeger on Tuesday December 17, 2019 @02:54AM
(#21811569)
A good example would be a case switch, that ran the first block that evaluated to true (lisp has this, many languages don't). That being said, custom control structures can abstract away some things.
Re:Why Lisp macros are cool, a Perl perspective (2005)
by bjoli on Tuesday December 17, 2019 @03:32AM
(#21811760)
Delimited gotos. Many lacks proper looping constructs. CL has a package a macro that gives you a limited version delimited continuations which are handy for some situations.
Re:Why Lisp macros are cool, a Perl perspective (2005)
by comex on Tuesday December 17, 2019 @05:01AM
(#21812174)
0.9^2 = 0.81, so you're saying that only 81% of macros are crap? :)
Re:Why Lisp macros are cool, a Perl perspective (2005)
by a1369209993 on Tuesday December 17, 2019 @01:44PM
(#21817051)
I think they meant squaring the fraction of good macros: 0.1^2 = 0.01, so 99% are crap. As someone who likes and uses cpp quite a bit, I think, if that isn't true anymore, it's only because most of the people who would have written crap macros have moved to writing python or javascript or whatever instead of C or C++.