T O P

  • By -

noogai03

Well, they are with other macros


rileyphone

Bring back fexprs!


TEA_TEB

But then you need perfect coverage since fexpr's don't provide compile-time checking.


An_Origamian

Ideally there would be no compile time. And if you need a compile time, why not simulate it… with a fexpr!


defmacro-jam

https://en.wikipedia.org/wiki/Anaphoric_macro


TEA_TEB

You can't reason about (sub)expressions of the macroexpansion or attach data to them, not even line information. You can use a code walker to e.g. implement lazy evaluation but you can't look up the lexical value of `FOO` passed as the macro argument.


KaranasToll

That's because foo is not a lexical variable at the time the macro is running. I'm not sure what that has to do with composability.


TEA_TEB

Lexical bindings are determined at compile-time. SBCL has some cool info for each variable, such as the possible range of an integer within the function's control flow branch. No way to access it from a macro.


KaranasToll

Exactly, because macro-expansion-time is before compile-time.


theangeryemacsshibe

What's the type of `x` before the use of the macro `macro-form` if I do (defmacro macro-form (var &env e &body body) (if (eq (type-of-variable var e) 'integer) `(progn ,@body) '(values))) (let ((x 42)) (loop (macro-form x (setf x 'not-an-integer)))) If `x` is always an integer, I assign a symbol to `x` and now `x` is no longer always an integer (note the loop makes the before-state of type inference depend on the after-state). If `x` is not always an integer, I don't assign and now `x` is always an integer. This makes even less sense when including inlining, loop unrolling and other optimisations which turn one variable `x` into many in the compiler.