Note that there are some explanatory texts on larger screens.

plurals
  1. POAre there whole-program-transforming macros in Lisp or Scheme?
    primarykey
    data
    text
    <p>I have seen one answer of <strong><a href="https://stackoverflow.com/questions/2307562/how-does-lisp-let-you-redefine-the-language-itself/2307627#2307627">How does Lisp let you redefine the language itself?</a></strong> Stack Overflow question (answered by Noah Lavine):</p> <blockquote> <p>Macros aren't quite a complete redefinition of the language, at least as far as I know (I'm actually a Schemer; I could be wrong), because there is a restriction. A macro can only take a single subtree of your code, and generate a single subtree to replace it. Therefore you can't write whole-program-transforming macros, as cool as that would be.</p> </blockquote> <p>After reading this I am curious about whether there are "whole-program-transforming macros" in Lisp or Scheme (or some other language).</p> <p>If not then why?</p> <ul> <li>It is not useful and never required?</li> <li>Same thing could be achieved by some other ways?</li> <li>It is not possible to implement it even in Lisp?</li> <li>It is possible, but not tried or implemented ever?</li> </ul> <p><strong>Update</strong></p> <p>One kind of use case e.g.</p> <p>As in stumpwm code here are some functions all in different lisp source files uses a dynamic/global defvar variable <strong>*screen-list*</strong> that is defined in <em>primitives.lisp</em> , but used in <em>screen.lisp</em>, <em>user.lisp</em>, <em>window.lisp</em>. (Here each files have functions, class, vars related to one aspect or object)</p> <p>Now I wanted to define these functions under the closure where <strong>*screen-list*</strong> variable available by let form, it should not be dynamic/global variable, But without moving these all functions into one place (because I do not want these functions to lose place from their related file) So that this variable will be accessible to only these functions.</p> <p>Above e.g. equally apply to label and flet, so that it will further possible that we could make it like that only required variable, function will be available, to those who require it.</p> <p>Note one way might be implement and use some macro defun_with_context for defun where first argument is context where let, flet variables definend. But apart from it could it be achieved by reader-macro as Vatine and Gareth Rees answered.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload