Improve docs on symbols.
[bpt/guile.git] / doc / sources / old-intro.texi
CommitLineData
009e2b30
NJ
1@node Introduction
2@chapter Introduction
3
4Guile is an interpreter for Scheme, a clean, economical programming
5language in the Lisp family. You can invoke Guile from the shell to
6evaluate Scheme expressions interactively, or use it as an interpreter
7for script files. However, Guile is also packaged as a library, to be
8embedded as an extension language into other applications. The
9application can supplement the base language with special-purpose
10functions and datatypes, allowing the user to customize and extend it by
11writing Scheme code.
12
13In its simplest form, Guile is an ordinary interpreter. The
14@code{guile} program can read and evaluate Scheme expressions entered
15from the terminal. Here is a sample interaction between Guile and a
16user; the user's input appears after the @code{$} and @code{guile>}
17prompts:
18
19@example
20$ guile
21guile> (+ 1 2 3) ; add some numbers
226
23guile> (define (factorial n) ; define a function
24 (if (zero? n) 1 (* n (factorial (- n 1)))))
25guile> (factorial 20)
262432902008176640000
27guile> (getpwnam "jimb") ; find my entry in /etc/passwd
28#("jimb" ".0krIpK2VqNbU" 4008 10 "Jim Blandy" "/u/jimb"
29 "/usr/local/bin/bash")
30guile> @kbd{C-d}
31$
32@end example
33
34Guile can also interpret script files. For example, here is a Guile script
35containing a script which displays the
36
37
38application can
39supplement the base language with its own functions, datatypes and
40syntax, allowing the user to extend and
41
42
43 Guile interpret
44
45. An
46application the Guile interpreter to allow
47
48
49, allowing
50applications to incorporate the Scheme interpreter for customization
51
52[[interactive]]
53[[script interpreter]]
54[[embedded]]
55
56[[other languages]]
57The concept of an extension language library does not originate with
58Guile. However, Guile is the first to offer users a choice of languages
59to program in.
60
61
62Guile currently supports Scheme and Ctax , and we expect to support Emacs Lisp in the near future.
63
64
65Scheme is powerful enough that other languages can be
66conveniently translated into it,
67
68However, unlike other extension packages, Guile gives users a choice of
69languages to program in. Guile can
70
71
72In this sense, Guile resembles the Tcl and Python packages, providing
73both an ordinary interpreter and an extension language library.
74However, unlike those packages, Guile supports more than one programming
75language.
76
77; users can
78write Scheme code to control and customize applications which
79incorporate Guile
80
81, adding their own functions,
82datatypes, and syntax, to allow the user to programm
83
84
85link it into your own programs to make them
86
87
88
89Guile is a library containing an interpreter for Scheme, a complete but
90economical programming language, which the developer can customize to
91suit the application at hand by adding new functions, data types, and
92control structures. These may be implemented in C, and then
93``exported'' for use by the interpreted code. Because Guile already
94provides a full-featured interpreter, the developer need not neglect the
95language's design in order to concentrate on code relevant to the task.
96In this way, Guile provides a framework for the construction of
97domain-specific languages.
98
99Guile provides first-class functions, a rich set of data types,
100exception handling, a module system, and a powerful macro facility.
101Guile also supports dynamic linking and direct access to Unix system
102calls. Releases in the near future will support a source-level
103debugger and bindings for the Tk user interface toolkit.
104
105
106
107Guile is a framework for writing applications controlled by specialized
108languages. In its simplest form, Guile is an interpreter for Scheme, a
109clean, economical programming language in the Lisp family. However,
110Guile is packaged as a library, allowing applications to link against it
111and use Scheme as their extension language. The application can add
112primitive functions to the language, implement new data types, and even
113adjust the language's syntax.
114
115
116
117[the introduction is probably not what Jim has in mind; I just took the
118one I had in earlier, since the file had the same name intro.texi]
119
120Guile is an implementation of the Scheme programming language, but, like
121other modern implementations of Scheme, it adds many features that the
122community of Scheme programmers considers necessary for an ``industrial
123strength'' language.
124
125Examples of extensions to Scheme are the module system
126(@pxref{Modules}), the Unix system programming tools (@pxref{POSIX
127system calls and networking} and @pxref{The Scheme shell (scsh)}), an
128interface to @emph{libtool} to make it easier to add C libraries as
129primitives (@pxref{Linking Guile with your code}), and (FIXME add more).
130
131On top of these extensions, which many other Scheme implementations
132provide, Guile also offers the possibility of writing routines in other
133languages and running them simultaneously with Scheme. The desire to
134implement other languages (in particular Emacs Lisp) on top of Scheme is
135responsible for Guile's only deviation from the R4RS @footnote{R4RS is
136the Revised^4 Report on the Algorithmic Language Scheme, the closest
137thing to a standard Scheme specification today} Scheme standard
138(@cite{r4rs}): Guile is case sensitive, whereas ``standard'' Scheme is
139not.
140
141But even more fundamentally, Guile is meant to be an @emph{embeddable}
142Scheme interpreter. This means that a lot of work has gone into
143packaging the interpreter as a C library (@pxref{A Portable C to Scheme Interface} and @pxref{Scheme data representation}).
144
145This reference manual is mainly driven by the need to document all the
146features that go beyond standard Scheme.
147
148@menu
149* Getting started::
150* Guile feature list::
151* What you need to use Guile::
152* Roadmap to the Manual::
153* Motivation for Guile::
154* History of Guile::
155@end menu
156
157@node Getting started
158@section Getting started
159
160We assume that you know how to program in Scheme, although we do not
161assume advanced knowledge. If you don't know Scheme, there are many
162good books on Scheme at all levels, and the Guile Tutorial might give
163you a good enough feel for the language. We also assume that you know
164how to program in C, since there will be many examples of how to program
165in C using Guile as a library.
166
167Many diverse topics from the world of Unix hacking will be covered here,
168such as shared libraries, socket programming, garbage collection, and so
169forth. If at any time you feel you don't have enough background on a
170given topic, just go up a level or two in the manual, and you will find
171that the chapter begins with a few paragraphs that introduce the topic.
172If you are still lost, read through the Guile tutorial and then come
173back to this reference manual.
174
175To run the core Guile interpreter and extension library you need no more
176than a basically configured GNU/Unix system and the Guile sources. You
177should download and install the Guile sources (@pxref{Obtaining and
178Installing Guile}).
179
180
181@node Guile feature list
182@section Guile feature list
183
184In a reductionist view, Guile could be regarded as:
185@itemize @bullet
186@item
187An R4RS-compliant Scheme interpreter.
188
189@item
190Some Scheme features that go beyond the R4RS standard, notably a module
191system, exception handling primitives and an interface to Aubrey
192Jaffer's SLIB.
193
194@item
195A symbolic debugger for Scheme, and gdb extensions to facilitate
196debugging libguile programs.
197
198@item
199An embeddable version of the same interpreter, called @emph{libguile}.
200
201@item
202A portable high level API on top of libguile (the @code{gh_} interface).
203
204@item
205A collection of bundled C libraries with a Guile API. As we write, this
206list includes:
207
208@table @strong
209@item Rx
210a regular expression library.
211
212@item Unix
213a low-level interface to the POSIX system calls, socket library
214and other Unix system services.
215
216@item Tk
217an interface to John Ousterhout's Tk toolkit.
218
219@end table
220
221@item
222A set of tools for implementing other languages @emph{on top of Scheme},
223and an example implementation of a language called @emph{Ctax}.
224
225
226@end itemize
227
228
229@node What you need to use Guile
230@section What you need to use Guile
231
232
233@node Roadmap to the Manual
234@section Roadmap to the Manual
235
236@node Motivation for Guile
237@section Motivation for Guile
238
239@node History of Guile
240@section History of Guile
241
242@page
243@node Using Guile
244@chapter Using Guile
245
246[I think that this might go in the appendix in Jim's view of the manual]
247
248@page
249@node Invoking Guile
250@appendix Invoking Guile
251 --- mentions read-eval-print loops
252 --- both the SCSH and GAWK manuals relegate invocation details
253 to an appendix. We can give examples in the introduction.
254
255@table @samp
256@item -h
257@itemx --help
258Display a helpful message.
259@item -v
260@item --version
261Display the current version.
262@item --emacs
263To be used for emacs editing support.
264@item -s @var{file}
265Process @var{file} as a script then quit. This is a terminating option:
266any further command line arguments can be accessed by the script using
267the @code{(program-arguments)} procedure.
268
269An executable script can start with the following:
270
271@smallexample
272#!/usr/bin/guile -s
273!#
274@end smallexample
275
276Note the @code{!#} token on the second line. It is very important
277to include this token when writing Guile scripts. Guile and SCSH,
278the Scheme shell, share the convention that @code{#!} and
279@code{!#} may be used to mark block comments (@pxref{Block
280comments and interpreter triggers}). If the closing @code{!#}
281token is not included, then Guile will consider the block comment
282to be unclosed, and the script will probably not compile
283correctly.
284
285It is also important to include the @samp{-s} option at the
286beginning of the Guile script, so that Guile knows not to behave
287in an interactive fashion.
288
289@end table
290