From: Pascal J. B. <pj...@in...> - 2012-04-25 23:24:32
|
"Yves S. Garret" <you...@gm...> writes: > 1. Are there any differences between CLISP and Clozure? If so, how > substantial are they? Which one would be a good place to start > for someone new? Both are good implementation to start with. > 2. Say I have a file hello_world.lisp. In that file I have the > function print. How do I execute that function from the command > line? $ clisp hello_world:print ? Depends on what's in this file exactly. While the underline character seems to be more "portable" than the dash for file names (eg. it's advised to use the following regexp for maximally portable file names: /[A-Z0-9_]{1,8}\.[A-Z0-9_]{1,3}/), as a lisper I prefer to use a dash in file names instead of an underline. It's in the lisp style, and it's easier to type: just a key instead of shift combination. So, let's assume a file named hello-world.lisp, containing: ----(hello-world.lisp)-------------------------------------------------- (defun hw () (format t "~%Bonjour le monde !~%") (values)) ------------------------------------------------------------------------ then you can run it from the unix command line with: $ clisp -norc -ansi -q -x '(progn (load "/tmp/hello-world.lisp" :verbose nil) (values))' -x '(hw)' Bonjour le monde ! $ But one wonders why you would want to do that? I mean, call a lisp function from the unix shell? Either you are implementing a unix script in clisp, in which case you should name your file hw, and edit it to contain: ----(hw)---------------------------------------------------------------- #!/usr/bin/clisp -q -ansi -norc (defun hw () (format t "~%Bonjour le monde !~%") (values)) (hw) ------------------------------------------------------------------------ $ chmod 755 hw $ ./hw Bonjour le monde ! $ or you are just writing lisp programs, and then you boot the lisp environment and stay in it to work: $ clisp i i i i i i i ooooo o ooooooo ooooo ooooo I I I I I I I 8 8 8 8 8 o 8 8 I \ `+' / I 8 8 8 8 8 8 \ `-+-' / 8 8 8 ooooo 8oooo `-__|__-' 8 8 8 8 8 | 8 o 8 8 o 8 8 ------+------ ooooo 8oooooo ooo8ooo ooooo 8 Welcome to GNU CLISP 2.49+ (2010-07-17) <http://clisp.org/> Copyright (c) Bruno Haible, Michael Stoll 1992, 1993 Copyright (c) Bruno Haible, Marcus Daniels 1994-1997 Copyright (c) Bruno Haible, Pierpaolo Bernardi, Sam Steingold 1998 Copyright (c) Bruno Haible, Sam Steingold 1999-2000 Copyright (c) Sam Steingold, Bruno Haible 2001-2010 Type :h and hit Enter for context help. ;; Loading file /home/pjb/.clisprc.lisp ... […] ;; Loaded file /home/pjb/.clisprc.lisp C/USER[1]> (load "/tmp/hello-world.lisp") ;; Loading file /tmp/hello-world.lisp ... ;; Loaded file /tmp/hello-world.lisp #P"/tmp/hello-world.lisp" C/USER[2]> (hw) Bonjour le monde ! C/USER[3]> -- __Pascal Bourguignon__ http://www.informatimago.com/ A bad day in () is better than a good day in {}. |