market trading Hello World in gcl and cl...

KaseemHester1980 Nov 13, 2012 12:27:13 AM

I put in gcl and clisp by means of yum in Fedora eight. The two seem to be to be typical packages in the Fedora distribution. Lisp is calme and amazing. There are some difficulties (as you may see under) in acquiring different implementations to run, and there seem to be a plethora of somewhat incompatible (or non-portable?) Lisp packages.

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

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

gcl works by using an internal Lisp purpose to magically make an executable. The approach supposedly entails compile Lisp to C, compile the Do an object file,hyperlink the object with some obscure libraries via an obscure system. I was not able to come across a command to fx trading compile the Do code with gcc, nor was I equipped to come across the locations of the url libraries (object libraries), and examples command lines for ld.

You can make a .o file by making use of -compile. You can make a .c file by using -do-file. You can make a .h file by utilizing -h-file. Nevertheless, I obtained website link mistakes when I tried to compile the .c with gcc. I gave up and utilized the magic Lisp purpose. A lot more on that beneath.

The executables are big. On my machine "howdy entire world" was 14MB. The similar binary produced from a Do "howdy globe" source file was 4KB. Granted, Lisp have to contain a full interpreter in each Lisp application, just in situation the code employs macros or some other code-made-on-the-fly element.

Create a file cl_hw.lisp

(princ "hellow stock trading software world!")

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 means "runs gcl devoid of printing the copyright discover, and do not enter the command line eval-print loop".

-load indicates "run the Lisp code". There is a distinctive Lisp functionality to compile and website link an object file with the Lisp object library. More on that under. You do not will need to use -compile to make an executable. You may possibly optionally use -compile. You *should* use -load and (systemsave-technique).

Correct absent you can expect to notice that Lisp appears to be to be missing newline characters. I get the impression that there are no normal bindings for management characters in Lisp. I'm confident there is some uncomplicated way to manage control chars, but I am spoiled by Perl (and Do) wherever n is moveable automated trading for newline (it works on all running methods), and Perl has string interpolation.Component of the Lisp resolution is to use (format) and perhaps the % and connected macros. The % isn't going to operate in clisp.

The gcl hello phrase instance is weird, and the writer did not clarify why the weirdness. As you can see above, a uncomplicated case in point will work high-quality. Nevertheless, the straightforward example are unable to be compiled to an executable. The only (considerably) documented technique to get an executable is to use a Lisp perform (systemsave-process).

File hello1.lisp

(defun sitop-degree ()

(format t "hello world!%" )

)

(systemsave-process "hi")

Develop an executable

gcl -batch -load hello1.lisp

The title of the exe is tough coded in the script to be "hi there". The following is a session transcript

zeus clisp$ cat hello1.lisp

(defun sitop-degree ()

(format t "hello there planet!%" )

)

(systemsave-system "howdy")

zeus clisp$

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

gcl wants to know the title of the purpose that will be major() in the C code. This is sitop-level() and by making use of (defun) we have outlined this functionality. We can (defun principal() ...) but we have to use a lot more system calls, and we have to add a (give up) to our (defun). Even worse, once this is completed, I can't come across a way to avert the GNU license communication from printing. Observe in the examples over that the gcl license did not print, but in the up coming case in point, the license *does* print. Heaven only is aware of why.

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

zeus clisp$ cat hello2.lisp(defun primary ()(format t "hi globe!%" )(stop))(setf process*top rated-degree-hook* 'main)(systemsave-method "hello2")zeus clisp$ gcl -batch -load hello2.lispzeus clisp$ ls -l hello2*-rwxrwxr-x one mst3k mst3k 14132764 2008-08-11 1043 hello2-rw-rw-r-- one mst3k mst3k131 2008-08-11 1040 hello2.lisp-rw-rw-r-- 1 mst3k mst3k332 2008-08-eleven 1022 hello2.lispzeus clisp$ ./hello2GCL (GNU Typical Lisp)two.six.7 ANSIAug 14 2007 173505Source License LGPL(gcl,gmp), GPL(unexec,bfd)Binary LicenseGPL because of to GPL'ed components (READLINE BFD UNEXEC)Modifications of this banner have to keep detect of a compatible licenseDedicated to the memory of W. SchelterUse (enable) to get some simple facts on how to use GCL.hi there earth!zeus clisp$ ./hello2 -batchzeus clisp$

You may discover a lot more data at these web-sites

http//en.wikibooks.org/wiki/Frequent_Lisp

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