In my free time (which I have very little), I’m learning the Lisp programming language. After doing some search, I decided to go with Common Lisp and installed SBCL.
I’m using a GNU/Linux machine. Following command helped me to install the SBCL on my computer.
After installation, check for the version and you can confirm the installation.
Write only sbcl
in the Terminal and it’ll open the true REPL for you. In order to quit or exit the REPL you need to write (quit)
.
*
is the prompt. You can type the Lisp code now.
You can directly write 10
or "hello, world"
(use double quotes) as these are the literal values.
If you try to write 10
as (10)
or "hello, world"
as ("hello, world")
you’ll get errors. For example,
You’re now in true REPL mode. For now, to exit, type 0
and press Enter.
You got the error because, in simple terms, after open paren, Lisp expects to have something that can execute. For example, (+ 3 4)
works as +
will execute on 3
and 4
values.
Here is the hello, world in Common Lisp.
Here, format
print on terminal
or t
(actually it is standard output) "hello, world"
string. You can write code within a file that should have .lisp
extension as hello.lisp
.
Yes, ;
is used to write comment in Lisp.
You can run the hello.lisp
program using following command.
Or open sbcl REPL and load
the file.