Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

forex news Hello World in gcl and cl...

I set up gcl and clisp through yum in Fedora eight. Each appear to be standard deals in the Fedora distribution. Lisp is cool and fantastic. There are some difficulties (as you are going to see under) in finding various implementations to operate, and there appear to be to be a plethora of fairly incompatible (or non-moveable?) Lisp packages.

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

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

gcl works by using an inside Lisp perform to magically make an executable. The course of action supposedly involves compile Lisp to C, compile the Do an object file,link the object with some obscure libraries through an obscure system. I was not capable to locate a command to etfs compile the C code with gcc, nor was I capable to discover the areas of the backlink 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 working with -c-file. You can make a .h file by employing -h-file. Nonetheless, I obtained website link problems when I tried to compile the .c with gcc. I gave up and utilised the magic Lisp function. Additional on that under.

The executables are big. On my device "hi globe" was 14MB. The very same binary developed from a Do "hello entire world" resource file was 4KB. Granted, Lisp have to contain a total interpreter in just about every Lisp system, just in situation the code employs macros or some other code-produced-on-the-fly feature.

Make a file cl_hw.lisp

(princ "hellow anyoption entire world!")

Operate this command
clisp cl_hw.lisp

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

gcl -batch -load cl_hw.lisp

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

-load means "operate the Lisp code". There is a special Lisp functionality to compile and backlink an object file with the Lisp object library. Much more on that under. You do not need to have to use -compile to make an executable. You may well optionally use -compile. You *ought to* use -load and (systemsave-system).

Proper away you'll observe that Lisp would seem to be lacking newline characters. I get the impact that there are no typical bindings for manage characters in Lisp. I'm certain there is some straightforward way to handle control chars, but I am spoiled by Perl (and C) the place n is moveable forex news for newline (it functions on all functioning methods), and Perl has string interpolation.Part of the Lisp solution is to use (format) and probably the % and associated macros. The % doesn't function in clisp.

The gcl hi there phrase illustration is weird, and the author failed to explain why the weirdness. As you can see previously mentioned, a uncomplicated case in point performs high-quality. Even so, the easy case in point are unable to be compiled to an executable. The only (fairly) documented technique to get an executable is to use a Lisp functionality (systemsave-method).

File hello1.lisp
(defun sitop-level ()
(format t "hi there earth!%" )
(systemsave-system "hi")

Create an executable
gcl -batch -load hello1.lisp

The identify of the exe is challenging coded in the script to be "hello there". Right here is a session transcript
zeus clisp$ cat hello1.lisp
(defun sitop-level ()
(format t "hi globe!%" )
(systemsave-program "hello")
zeus clisp$
zeus cedar finance clisp$ gcl -batch -load hello1.lispzeus clisp$ lltotal 13864-rwxrwxr-x 1 mst3k mst3k 14132764 2008-08-11 1028 hi 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 desires to know the title of the function that will be most important() in the C code. This is sitop-stage() and by using (defun) we have defined this perform. We can (defun principal() ...) but we have to use a lot more program calls, and we have to include a (give up) to our (defun). Even even worse, the moment this is carried out, I can't find a way to avoid the GNU license message from printing. Discover in the examples over that the gcl license did not print, but in the upcoming illustration, the license *does* print. Heaven only knows why.

The session transcript. I use forex traders "cat" so you can see the contents of hello2.lisp. I also experimented with ./hi -batch, to no avail. The license didn't print, but neither did my output.
zeus clisp$ cat hello2.lisp(defun most important ()(format t "hello planet!%" )(quit))(setf method*top-level-hook* 'main)(systemsave-process "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-- 1 mst3k mst3k131 2008-08-11 1040 hello2.lisp-rw-rw-r-- 1 mst3k mst3k332 2008-08-11 1022 hello2.lispzeus clisp$ ./hello2GCL (GNU Widespread Lisp)2.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 need to keep notice of a suitable licenseDedicated to the memory of W. SchelterUse (assist) to get some basic data on how to use GCL.howdy entire world!zeus clisp$ ./hello2 -batchzeus clisp$

You could come across a lot more information at these sites



Don't be the product, buy the product!