-
public interface InnerScopeDependent
This is a marker interface that signals that a class implementing theMacro
interface is a special macro that needs to be evaluated in the scope that was starting inside the macro. It means that the code of the macro will see all user defined macros that are defined inside the macro use.This helps the implementation and the simplifies the use of macros like
Snippet
in the extension package. That macro reads a snippet from a file. The argument of the macro is the name of the snippet. There are other parameters that can also be defined. One of them is the file name. It is read from the user defined macrofileName
. If there are many snippets read from the same file, then it is a good practice to define this macro outside of thesnippet
macro. If the scope of thefileName
parameter is only for this one snippet then it can be defined inside thesnippet
macro, for example:
This can be done, because then the macro{#snippet {@define fileName=SourceFileForASingleSnippet.java} single_snippet}
snippet
is evaluated callingjavax0.jamal.extensions.Snippet.evaluate()
the scope is still the one opened when processing the content of the macro. This is because the classjavax0.jamal.extensions.Snippet.evaluate()
implements this interface.Macros that want to register non-global user defined macros must not implement this interface. If they do so the defined macro will be registered into the scope that exists inside the macro itself. That scope is dropped right after the evaluation of the macro has finished.
The non
InnerScopeDependent
may freely define global macros as well as defined macros and export them to the parent scope.