4 ms·
I think it's fine. In the first occurrence, $(sourceCodeSnippet) is replaced in the code, and later evaluated (and the result of this evaluation will be passed
by S4M 7y ago
I think it's fine.
In the first occurrence, $(sourceCodeSnippet) is replaced in the code, and later evaluated (and the result of this evaluation will be passed to the const result).
In the second occurrence, it is replaced inside a string, so it doesn't get evaluated, but the source code is just treated as a string (and displayed in the error message).
Note that the macro nullthrows is just generating some code depending of sourceCodeSnippet, and this code will be evaluated later.
- perfunctory 7y agoSince this is a pseudo code it's hard to tell what the intended semantics are, but if as you say "the source code is just treated as a string", then it's still not right. What if sourceCodeSnippet contains double quotes? OP conveniently uses single quotes in their example getUser(db, ‘billy’) The whole point of lisp macros is that code is not treated as a string.
- stopachka 7y agoHi perfunctory, thanks for the thoughtful read : ). I'll update that snippet to include something like a `stringify` function, to make the intent more clear. In terms of the intended semantics: - In some ways my intent was to show these limitations: unless we get code as data structures, our macros would be very brittle.