[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.0.1 Hello World
Our first program is the typical Scheme "hello world" program. Put the
following code in a file called hello.scm
(this can be find in
‘examples/scheme/hello.scm’).
#!/usr/local/bin/guile -s !# (display "hello world") (newline) |
Then run guile on it. One way to do so is to start up guile and load this file:
<shell-prompt> guile guile> (load "hello") |
Another way is to make the file executable and execute it directly.
Notice how Guile recognizes a -s
option which tells it to run a
script and then exit. Guile also has a new type of block comment
enclosed by #!
and !#
, so that you can make executable
Scheme scripts with the standard UNIX #!
mechanism.
In the given example, the first line is used to invoke the Guile
interpreter (make sure you correct the path if you installed Guile in
something other than /usr/local/bin). Once Guile is invoked on this
file, it will understand that the first line is a comment. The comment
is then terminated with !#
on the second line so as to not
interfere with the execution mechanism.