LinuxCommandLibrary

guile

Execute Scheme code

TLDR

Start a REPL (interactive shell)

$ guile
copy

Execute the script in a given Scheme file
$ guile [script.scm]
copy

Execute a Scheme expression
$ guile -c "[expression]"
copy

Listen on a port or a Unix domain socket (the default is port 37146) for remote REPL connections
$ guile --listen=[port_or_socket]
copy

SYNOPSIS

guile [OPTION]... [FILE] [ARG]...

PARAMETERS

-h, --help
    Display help message and exit

-V, --version
    Display version information and exit

-L DIR, --load-path=DIR
    Add DIR to the front of Guile's load path

-l FILE, --load=FILE
    Load Scheme source code from FILE before reading other files

-s, --script=SCRIPT
    Use SCRIPT as name for current program (with -s reads stdin)

-c EXPR, --eval=EXPR
    Evaluate EXPR as Scheme code then exit

-e FUNC, --entry=FUNC
    After reading script, apply FUNC to command line args

--language=LANG
    Use language LANG (e.g., 'scheme') instead of default

-q, --no-auto-compile
    Disable automatic compilation of source files

--listen[=PORT]
    Listen for REPL connections on PORT (default 37146)

DESCRIPTION

Guile, the GNU Ubiquitous Intelligent Language for Extensions, is an implementation of the Scheme programming language tailored for embedding in applications. The guile command launches the Guile REPL (Read-Eval-Print Loop) for interactive Scheme programming or executes scripts.

Designed as the GNU project's extension language, Guile enables C programs (and others) to dynamically load and run Scheme code via a robust foreign function interface. It supports tail-call optimization, continuations, a full numeric tower, threads, and modules compliant with R5RS and large parts of R7RS.

Key uses include scripting, rapid prototyping, and extending tools like GnuCash (financial software), LilyPond (music engraving), and GDBM. Guile's bytecode compiler and optimizer enhance performance. Scripts typically use #!/usr/bin/env guile -s shebang for standalone execution.

In interactive mode, users evaluate expressions, load libraries with (use-modules ...), and access meta-commands via comma-prefix (e.g., ,q to quit). Guile excels in metaprogramming and is highly extensible.

CAVEATS

Some options deprecated in Guile 3.x; prefer guild for compiling modules. Not fully R7RS-compliant. Scripts need proper shebang for portability.

REPL META-COMMANDS

Prefix with comma: ,q quit, ,l file load, ,a autoload, ,? help.
Enable with (use-modules (system repl repl)).

SCRIPT EXAMPLE

#!/usr/bin/env guile -s
!#
(display "Hello, Guile!\n")
(exit 0)

HISTORY

Initiated in 1992 by Tom Lord for GNU; first release Guile 1.0 in 1998. Evolved through versions 2.x (2011+) with compiler, reaching 3.0 in 2021 emphasizing modularization and guild tool.

SEE ALSO

guild(1), guile-tools(1), lua(1), python3(1)

Copied to clipboard