Sign in to follow this  
Genjix

clisp beginner questions

Recommended Posts

i know clisp is interpreted like perl, bash or python, does it use bytecode like python or java and can it be compiled into a binary? i am able to run the clisp interpreter in the interactive console and type code in, use the load function to load in my hello-world
(defun hello-world()
	(format t "Hello, World!!!"))

(hello-world)

(the last line is me trying to call hello-world in the global namespace like in perl or python) can i compile this to binary? can i compile this to bytecode? how can i just get the interpreter to interpret this silently and exit
$ clisp -c hello.lisp
$ ./a.out
Hello, World!!!
$ clisp -b hello.lisp
$ clisp hello.bytecode
Hello, World!!!
$ clisp hello.lisp
Hello, World!!!
$
how can I get these behaviours? Thanks btw: how can i do newlines?

Share this post


Link to post
Share on other sites
There is bytecode - the files have a "fas" extension. I don't know that you can compile to real binary. You can do "clisp a.lisp" to load and run the code in that file or "clisp a.fas" to run the bytecode in that file or "clisp -c a.lisp" to compile a lisp file to bytecode or "clisp --h" to learn all these.

(format t "~%~%~%") will write three newlines

Share this post


Link to post
Share on other sites
GNU CLISP uses a bytecode vm. Many other lisps compile to native code. clisp is fast enough for most purposes though. If you want speed don't forget to (compile ...) your functions, else CLISP will have to convert your sourcecode to bytecode everytime you call them.

Creating standalone executables is somewhat complicated. Usually you don't create standalone executables but save an image and distribute the image-loader together with your image and a startscript.

Look here and here.

Share this post


Link to post
Share on other sites
ok, so why does the above code do this when i load the file

genjix@linux:~/media/programming/clisp> clisp hello.lisp
WARNING: *FOREIGN-ENCODING*: reset to ASCII
Hello, World!!!

I assume it means the encoding of the text file? what encoding should i use?

Share this post


Link to post
Share on other sites
I'd recommend SLIME for Emacs as IDE for writing Lisp-code.

It makes writing lisp so much easier. Especially the hyperspec lookup, autoindent and parens-matching are indispensable.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this