[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
6.23.1 Using Other Languages
There are currently only two ways to access other languages from within
Guile: at the REPL, and programmatically, via compile
,
read-and-compile
, and compile-file
.
The REPL is Guile’s command prompt (see section Using Guile Interactively).
The REPL has a concept of the “current language”, which defaults to
Scheme. The user may change that language, via the meta-command
,language
.
For example, the following meta-command enables Emacs Lisp input:
scheme@(guile-user)> ,language elisp Happy hacking with Emacs Lisp! To switch back, type `,L scheme'. elisp@(guile-user)> (eq 1 2) $1 = #nil
Each language has its short name: for example, elisp
, for Elisp.
The same short name may be used to compile source code programmatically,
via compile
:
elisp@(guile-user)> ,L scheme Happy hacking with Guile Scheme! To switch back, type `,L elisp'. scheme@(guile-user)> (compile '(eq 1 2) #:from 'elisp) $2 = #nil
Granted, as the input to compile
is a datum, this works best for
Lispy languages, which have a straightforward datum representation.
Other languages that need more parsing are better dealt with as strings.
The easiest way to deal with syntax-heavy language is with files, via
compile-file
and friends. However it is possible to invoke a
language’s reader on a port, and then compile the resulting expression
(which is a datum at that point). For more information,
See section Compiling Scheme Code.
For more details on introspecting aspects of different languages, See section Compiler Tower.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on April 20, 2013 using texi2html 5.0.