[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

[LISP] Møde i Lisp-gruppen



Vi havde igår møde i Lisp-gruppen.

På mødet prøvede vi at lave et program, der kunne noget. Resultatet er
nedenfor. Vi eksperimenterede med sbcl, gcl og CLISP - primært CLISP da vi
kunne få dennes command history til at virke, og da den kunne fortolke på
samme måde som perl. Da vi ikke have internetadgang på mødet, så var vi
lidt hæmmet af ikke at kunne fiske eksempelkode frem. Kristian Kallenberg
havde downloaded en reference guide. Men uden eksempler var den ikke til
stor hjælp. Jeg har fundet en netbog, som er væsentlig lettere
tilgængelig: Succesful Lisp. http://psg.com/~dlamkins/sl/contents.html

Vi prøvede at se, om vi kunne få sbcl og gcl til at compile koden, men det
er tydeligvis ikke lige så nemt som i C. Jeg har mailet Robert Strandh
(fra hyggemødet d. 20 aug). Han siger, at man ikke skal bruge Lisp til
noget, der er Unix-nært (F.eks. en replacement for wc). Lisp er bedre til
applikationer som Gimp og Xfig. Lisps libc er lisp-compileren, så skal du
køre (uden at ændre) lisp, så skal lisp-compileren være installeret (se
mail fra Robert nedenfor).

Næste møde er planlagt til:

  Tirsdag, 2002-sep-17 kl. 19:00
  Cafeen
  Kapelvej 44
  2200 København N

Der vil være spisning mellem kl. 18 og 19 samme sted (altså ikke
Vagabondos!).


/Ole

---------- Forwarded message ----------
#!/usr/bin/clisp

; Forsøgskode
;
; Filen foo:
; ø,æ,århus,aarhus festue,Linje 1:abc,cde,123; fgh,ijk,
; Linje 2:afjfjbc,cde,123; fgh,ijk,

(setq fh (open "foo"))
(setq s (read-line fh))
(setq k (read-line fh))
;(write (length k))

(setq f 3)
(do ((f 2))
    (
     (and (> f 7) (> f 4)) f
     )
    (setq f (+ 1 f))
)

(setq v ())
(setq s1 0)
(dotimes (n (length s))
  (setq c (aref s n))
;  (write-char c)
  (cond ((or
	  (eq c #\,)
	  (eq n (- (length s) 1)))
	 (setq ss (string-capitalize (substring s s1 n)))
; (string-upcase (substring "hej" 0 1))
;	 (set (aref ss 0) )
;(string-upcase (substring ss 0 1))
	 (push ss v)
;	 (write ss)
;	 (write-char #\Newline)
;	 (write (reverse v))


	 (setq s1 (+ n 1))
	 )
	)
  )
(setq finis (reverse v))
(write finis)
(write-char #\Newline)
(write
 (sort finis 'string<)
)
; (sort (vector "1" "2" "3") 'string>)

---------- Forwarded message ----------
From: Robert STRANDH <sslug@sslug>
Date: Wed, 4 Sep 2002 07:42:27 +0200
To: Ole Tange <sslug@sslug>
Subject: Re: Compiling LISP


Hello again,

Ole Tange writes:
 > Erh?! If what I am writing is communicating with something else (say, a
 > replacement for wc) then how can I test the program if not by running:
 >
 > cat foo | lisp-wc | program-that-does-something-to-wc-output

Well, you see, Lisp is a very bad choice if you want to write a
replacement of wc.  You *can* do it, but you are playing by the rules
of the Unix programming environment, so obviously C will have an
edge.  However, if you want to program end-user applications, let's
say something like the Gimp or Xfig or something like that, then you
have a much larger application.  The external interface to the Unix
environment will represent a much smaller part of the application, so
the advantage of C in the Unix programming environment will dwindle in
comparison with the huge advantage of Lisp for writing the application
itself.

 > But what if Lisp is not available at my destination platform? How do I
 > create a raw binary that will run without Lisp?

No Lisp program runs without the Lisp system, the same way that no C
program runs without libc.  Think of the Lisp system as the runtime
library for running Lisp.  Whether you leave Lisp in a shared
executable and just deliver your own additions (which would correspond
to generating a dynamically linked C executable) or save the entire
Lisp system with the additions (which corresponds to static linking of
the C program) is a matter of what you want to accomplish.

The same way that it is preferable to always have the shared libc
installed and deliver only dynamically linked executables, it is
preferable to have Lisp installed on the machine and only deliver
compiled files.

 > In C I need a C-compiler to compile to binary. If I link -static then I
 > will not need neither C-compiler nor libc at runtime. If I link normally I
 > will need libc at runtime.

Exactly.

 > From what you have written it seems Lisp needs compiler at runtime and

It's the other way around.  The Lisp definition *requires* that the
compiler be around at runtime.  This is one of the great advantages
with Lisp, since it makes customisation and scripting trivial.  Of
course, if you don't use it, you can always remove it.  Some of the
Lisp vendors sell `runtimes' without compilers.  Now, you won't need
the Lisp compiler for `wc', but you might for something like the
Gimp.

 > that compiled Lisp-programs are always linked static.

Neither of this is in the language definition so it depends on the
system.  But with SBCL and CMUCL you have the same choice as C.  The
method I showed you corresponds to static linking.  But you can also
start the Lisp system and load the compiled function you want to run.
That method corresponds to dynamic linking, and the Lisp system would
correspond to your dynamicly linked libc.

 > But this will require installation of Lisp on the destination host, right?

With that method, Lisp itself is a trivial program that loads the core
file and runs the first function.  Then, you can just put the Lisp
system in /usr/lib/myapp/lisp.  I know that it is possible to
integrate the lisp system into your executable as well.  If you really
want to know how to do this, I can find out (I just never imagined
anyone would find this important, so I don't have the answer ready).
But you have to give me a few days, since I am leaving for the US in
two hours and will stay away until monday.

 > But this will drastically limit my expressive powers: I very often write
 > perl -e to do stuff on 100000 files that is needed in the program. In SBCL
 > I do not even have command history. And in CLISP the command history seems
 > to recall the last bad command - and not just the last command.

Most Lisp systems today are used together with Emacs, who is
repsonsible for the command history, indentation, sending definitions
to Lisp for compilation, looking up documentation, and more.

I would advice you to stick to perl and C for the type of file
processing you are doing and only use Lisp for what I call "end-user
applications".

If you really want to learn about Lisp, I would advice you to
temporarily forget what you know of programming in other languages and
just play around with the interactive Lisp system through Emacs.
Programming in Lisp is very different from programming in other
languages.  If you try to accomplish the same thing in Lisp that you
already know how to do in C or perl (a seeminly reasonable thing to
do), you will largely miss the point.  Once you see how much easier it
is to get the work done in Lisp, I hope you will realize that the
question of how to make it integrate with Unix is almost without
importance (it has to be done one day, but since I write an
application at most every so many years, I only have to do it very
rarely).  Whether it is statically or dynamically linked is also
almost without importance, since the application takes up so much more
space than the runtime library.

Take care and good luck,
-- 
Robert Strandh

---------------------------------------------------------------------
Greenspun's Tenth Rule of Programming: any sufficiently complicated C
or Fortran program contains an ad hoc informally-specified bug-ridden
slow implementation of half of Common Lisp.
---------------------------------------------------------------------




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:29 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *