1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 13:30:26 +02:00

Update documentation on <language>

* doc/ref/compiler.texi (Compiler Tower): Update.
This commit is contained in:
Andy Wingo 2020-05-12 10:43:10 +02:00
parent 00a163add4
commit 6083020199

View file

@ -52,7 +52,8 @@ They are registered with the @code{define-language} form.
[#:parser=#f] [#:compilers='()] @ [#:parser=#f] [#:compilers='()] @
[#:decompilers='()] [#:evaluator=#f] @ [#:decompilers='()] [#:evaluator=#f] @
[#:joiner=#f] [#:for-humans?=#t] @ [#:joiner=#f] [#:for-humans?=#t] @
[#:make-default-environment=make-fresh-user-module] [#:make-default-environment=make-fresh-user-module] @
[#:lowerer=#f] [#:analyzer=#f] [#:compiler-chooser=#f]
Define a language. Define a language.
This syntax defines a @code{<language>} object, bound to @var{name} in This syntax defines a @code{<language>} object, bound to @var{name} in
@ -96,18 +97,23 @@ The language object will be returned, or @code{#f} if there does not
exist a language with that name. exist a language with that name.
@end deffn @end deffn
Defining languages this way allows us to programmatically determine When Guile goes to compile Scheme to bytecode, it will ask the Scheme
the necessary steps for compiling code from one language to another. language to choose a compiler from Scheme to the next language on the
path from Scheme to bytecode. Performing this computation recursively
builds transformations from a flexible chain of compilers. The next
link will be obtained by invoking the language's compiler chooser, or if
not present, from the language's compilers field.
@deffn {Scheme Procedure} lookup-compilation-order from to A language can specify an analyzer, which is run before a term of that
Recursively traverses the set of languages to which @var{from} can language is lowered and compiled. This is where compiler warnings are
compile, depth-first, and return the first path that can transform issued.
@var{from} to @var{to}. Returns @code{#f} if no path is found.
This function memoizes its results in a cache that is invalidated by If a language specifies a lowerer, that procedure is called on
subsequent calls to @code{define-language}, so it should be quite expressions before compilation. This is where optimizations and
fast. canonicalizations go.
@end deffn
Finally a language's compiler translates a lowered term from one
language to the next one in the chain.
There is a notion of a ``current language'', which is maintained in the There is a notion of a ``current language'', which is maintained in the
@code{current-language} parameter, defined in the core @code{(guile)} @code{current-language} parameter, defined in the core @code{(guile)}