Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.

Next: , Up: Other Languages   [Contents][Index]


6.24.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 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 Compilation.

For more details on introspecting aspects of different languages, See Compiler Tower.