Open rvs314 opened 1 day ago
Putting these definitions inside a library or module form makes them no longer top-level forms, which makes eval-when kinda useless.
The treatment of local expressions or definitions (those not at top level) that are wrapped in an eval-when depends only upon whether the situation eval is present in the list of situations. If the situation eval is present, the definitions and expressions are evaluated as if they were not wrapped in an eval-when form, i.e., the eval-when form is treated as a begin form. If the situation eval is not present, the forms are ignored; in a definition context, the eval-when form is treated as an empty begin, and in an expression context, the eval-when form is treated as a constant with an unspecified value.
The simplest way that I know of to provide some utility functions available at both expand and run time is to put them in their own library, separate from the one that uses them in syntax transformers.
The eval-when page in CSUG gives an example of how to use
eval-when
in order to make a definition available in multiple phases:This works when put directly into a file, but doesn't work when inside of a
library
ormodule
form:Loading this causes the following error:
The code does work if the definition of
nodups?
is wrapped in ameta
keyword, but this doesn't let you use it at runtime. Is there a way to get around this? Is this the expected behavior? If so, can it be documented? If not, what is the issue? I'd be happy to help fix it if need be.