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 8:32

>>50
Oh, and if by "manipulate lexer-level tokens" you mean things like concatenating symbols, or adding up numbers at compile-time, that's kind of the definition of having the entire language available during macro expansion. You can do whatever you want to the code. You could convert (foo bar baz) into an array containing the two symbols #(foo53bar baz-blah) without dropping back into the string reader, but by directly manipulating the data items from the source.

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