cedar finance Hello World in gcl and cl...

OrenDavis1940 Nov 4, 2012 10:42:42 PM

I mounted gcl and clisp through yum in Fedora eight. Both appear to be normal packages in the Fedora distribution. Lisp is neat and fantastic. There are some troubles (as you'll see beneath) in finding various implementations to operate, and there look to be a plethora of fairly incompatible (or non-transportable?) Lisp packages.

gcl is the GNU widespread lisp compiler and interpreter. It can interpret code, and it can compile to binary executables.

clisp is a widespread lisp interpreter. It is straightforward to use, but does not compile to binary executables.

gcl employs an internal Lisp functionality to magically make an executable. The process supposedly requires compile Lisp to C, compile the Do an object file,backlink the object with some obscure libraries by means of an obscure approach. I was not able to come across a command to binary options trading compile the Do code with gcc, nor was I able to uncover the places of the website link libraries (object libraries), and examples command lines for ld.

You can make a .o file by employing -compile. You can make a .do file by utilizing -c-file. You can make a .h file by working with -h-file. However, I got backlink mistakes when I experimented with to compile the .c with gcc. I gave up and utilized the magic Lisp function. Additional on that below.

The executables are enormous. On my machine "hi earth" was 14MB. The similar binary created from a Do "hi entire world" source file was 4KB. Granted, Lisp should consist of a entire interpreter in every single Lisp application, just in scenario the code makes use of macros or some other code-produced-on-the-fly feature.

Make a file cl_hw.lisp

(princ "hellow stocks to buy planet!")

Operate this command

clisp cl_hw.lisp

Or you can run this command to use gcl as an interpreter

gcl -batch -load cl_hw.lisp

-batch implies "runs gcl without having printing the copyright detect, and do not enter the command line eval-print loop".

-load implies "operate the Lisp code". There is a specific Lisp perform to compile and backlink an object file with the Lisp object library. Far more on that below. You do not need to have to use -compile to make an executable. You might optionally use -compile. You *need to* use -load and (systemsave-technique).

Correct away you are going to discover that Lisp seems to be lacking newline characters. I get the impact that there are no typical bindings for manage characters in Lisp. I'm guaranteed there is some effortless way to handle command chars, but I am spoiled by Perl (and C) in which n is moveable pennystocks2232.com for newline (it works on all working programs), and Perl has string interpolation.Aspect of the Lisp solution is to use (format) and probably the % and relevant macros. The % doesn't function in clisp.

The gcl hello there word instance is strange, and the writer failed to make clear why the weirdness. As you can see higher than, a easy instance will work wonderful. On the other hand, the simple case in point are not able to be compiled to an executable. The only (relatively) documented technique to get an executable is to use a Lisp functionality (systemsave-technique).

File hello1.lisp

(defun sitop-amount ()

(format t "hi globe!%" )

)

(systemsave-system "howdy")

Develop an executable

gcl -batch -load hello1.lisp

The title of the exe is hard coded in the script to be "hi there". Right here is a session transcript

zeus clisp$ cat hello1.lisp

(defun sitop-level ()

(format t "howdy globe!%" )

)

(systemsave-system "hello")

zeus clisp$

zeus cedar finance clisp$ gcl -batch -load hello1.lispzeus clisp$ lltotal 13864-rwxrwxr-x one mst3k mst3k 14132764 2008-08-eleven 1028 hi there-rw-rw-r-- one mst3k mst3k90 2008-08-eleven 1025 hello1.lisp-rw-rw-r-- one mst3k mst3k332 2008-08-eleven 1021 hello1.lispzeus clisp$ ./hellohello earth!zeus clisp$

gcl wants to know the identify of the purpose that will be main() in the C code. This is sitop-degree() and by using (defun) we have outlined this function. We can (defun main() ...) but we have to use far more technique calls, and we have to add a (stop) to our (defun). Even worse, when this is completed, I can not locate a way to prevent the GNU license communication from printing. Notice in the examples higher than that the gcl license did not print, but in the next illustration, the license *does* print. Heaven only knows why.

The session transcript. I use pennystocks4509.com "cat" so you can see the contents of hello2.lisp. I also experimented with ./hello -batch, to no avail. The license failed to print, but neither did my output.

zeus clisp$ cat hello2.lisp(defun primary ()(format t "howdy globe!%" )(quit))(setf program*top-stage-hook* 'main)(systemsave-method "hello2")zeus clisp$ gcl -batch -load hello2.lispzeus clisp$ ls -l hello2*-rwxrwxr-x one mst3k mst3k 14132764 2008-08-eleven 1043 hello2-rw-rw-r-- one mst3k mst3k131 2008-08-eleven 1040 hello2.lisp-rw-rw-r-- one mst3k mst3k332 2008-08-11 1022 hello2.lispzeus clisp$ ./hello2GCL (GNU Typical Lisp)two.six.seven ANSIAug 14 2007 173505Source License LGPL(gcl,gmp), GPL(unexec,bfd)Binary LicenseGPL due to GPL'ed elements (READLINE BFD UNEXEC)Modifications of this banner ought to keep notice of a compatible licenseDedicated to the memory of W. SchelterUse (enable) to get some basic info on how to use GCL.hello entire world!zeus clisp$ ./hello2 -batchzeus clisp$

You may possibly discover a lot more facts at these sites

http//en.wikibooks.org/wiki/Prevalent_Lisp

http//clisp.cons.org/impnotes/quickstart.html