Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Macro-writing challenge

Name: Anonymous 2016-01-16 13:19

Write a macro check-arguments-non-nil to be used in function definitions, that would expand to assertion about every argument being non-nil.
The intended usage of this macro:

(defun foo (a b c d)
(check-arguments-non-nil)
foo-body)


This should expand to:

(defun foo (a b c d)
(assert (and (not (null a)) (not (null b)) (not (null c)) (not (null d)))
(a b c d)
"Null argument in FOO")
foo-body)


The macro must work whatever the number and names of the function parameters.

Name: Anonymous 2016-01-21 7:30

>>46
>>41 (anti-lisp) is not >>43,45 (pro-lisp).

>>47
The entire Lisp syntax is implemented in character-by-character "reader macros", which are extensible to whatever you want at the raw syntax level. You can literally do infix Unicode mathematical operators, Python-style indentation awareness, whatever you want.

Beyond AST macros and reader macros, there's also compiler macros offering optional optimization-based equivalent transformations. There's plenty of ways to customize Common Lisp.

Regarding that C macro, I'm not even going to bother trying to parse that garble. At first glace, though, I will say it's generally bad form for macros to blindly insert local variable names into whatever it's generating, partially because in Lisp they're not just strings but symbols (which are interned & namespaced, and the macro & usage can be in different namespaces). The first step in converting it to Lisp would be to untangle that mess into a more sane expression.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List