I saw one answer. How does Lisp allow you to override the language itself? Question (answered Noah Lavigne):
Macros are not a complete redefinition of the language, at least as far as I know (I'm actually Schemer, I could be wrong), because there is a limitation. A macro can only take one subtree of your code and generate one subtree to replace it. Therefore, you cannot write macros that transform the entire program as cool as it would be.
After reading this, I wonder if there are macros that convert the entire program into Lisp or Scheme (or some other language).
If not, why?
- Is this not useful and not required?
- Could the same be done in other ways?
- Impossible to implement it even in Lisp?
- Perhaps, but have not tried or not implemented ever?
Update
One kind of use case for example.
Like the stumpwm code, here are some functions, everything in different Lisp source files uses the dynamic / global variable defvar * screen-list * , which is defined in primitives.lisp, but used in screen.lisp, user.lisp, window.lisp. (Here, each file has functions, a class, and options related to one aspect or object)
Now I would like to define these functions when closing, where the * screen-list * , available in the let form, it should not be a dynamic / global variable, but not moving all these functions to one place (because I do not want these functions lost space from their linked file) so that this variable is available only for these functions.
The above, for example, are equally applicable to the label and flet, so it will be possible that we could make it so that only the required variable, the function will be available to those who require it.
Note that one way could be to implement and use some defun_with_context macro for defun, where the first argument is the context, where let, flet variables are defined. But besides this, it can be achieved with the help of a macro reader like Batting and Gareth Rice.
macros lisp scheme transformation
Sharad
source share