Prev: Lisp and ncurses
Next: check for non empty string
From: joswig on 19 Dec 2009 13:51 On 19 Dez., 19:16, Cecil Westerhof <Ce...(a)decebal.nl> wrote: > > Use WITH-OPEN-FILE instead. > > >> (if (null *outputfile*) > > > If you set it, then the variable will not be NULL. > > I expected it to be set to nil if the file could not be opened. But that > is not the case. There can be case where OPEN returns nil - for example if you give :if-exists NIL , and it really does exist. > An exception will be generated. The with-open-file is > the way to go I think. The only 'disadvantage' is that when working with > several files I will get a deep nesting. But I can live with that. > Properly a better solution as I made myself. WITH-OPEN-FILE ensures that a stream is closed when it returns (for example with a non-local exit on an error). It is just a macro around UNWIND-PROTECT and OPEN. You can use OPEN with multiple-files, but you may then also want to use UNWIND-PROTECT to close them. That's a usual idiom. > > -- > Cecil Westerhof > Senior Software Engineer > LinkedIn:http://www.linkedin.com/in/cecilwesterhof
From: Cecil Westerhof on 19 Dec 2009 15:13 "joswig(a)corporate-world.lisp.de" <joswig(a)lisp.de> writes: >> Of-course clisp is a real programming language and not a scripting >> language like bash (which I want to replace with clisp), so I need to >> change my state of mind when scripting with clisp. > > Common Lisp is 'Common Lisp' or shorter 'CL'. > CLISP is an implementation of Common Lisp, usually. I try to keep me to the lingo. I just started with lisp. First I made a script in 'Emacs Lisp', just for the fun of it. But it was significant faster as a bash script which made use off awk. (When executing it five times with Emacs Lisp the average was 51 seconds (50-53) and with bash/awk the average was 114 (108-120).) Because of this (and because I like to use one language instead of several when I am scripting) I decided to switch to 'Emacs Lisp' for my scripting. But this works only really good for background scripts, because of this I decided to switch to 'CL' and at the moment I am using clisp. So I still have to learn a 'little'. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
From: joswig on 19 Dec 2009 15:27 On 19 Dez., 21:13, Cecil Westerhof <Ce...(a)decebal.nl> wrote: > "jos...(a)corporate-world.lisp.de" <jos...(a)lisp.de> writes: > >> Of-course clisp is a real programming language and not a scripting > >> language like bash (which I want to replace with clisp), so I need to > >> change my state of mind when scripting with clisp. > > > Common Lisp is 'Common Lisp' or shorter 'CL'. > > CLISP is an implementation of Common Lisp, usually. > > I try to keep me to the lingo. I just started with lisp. First I made a > script in 'Emacs Lisp', just for the fun of it. But it was significant > faster as a bash script which made use off awk. (When executing it five > times with Emacs Lisp the average was 51 seconds (50-53) and with > bash/awk the average was 114 (108-120).) Because of this (and because I > like to use one language instead of several when I am scripting) I > decided to switch to 'Emacs Lisp' for my scripting. But this works only > really good for background scripts, because of this I decided to switch > to 'CL' and at the moment I am using clisp. > So I still have to learn a 'little'. That's a good choice. CLISP, an implementation of Common Lisp ;-) , should be quite useful for that. It requires relatively little memory, has a byte code compiler and has useful support for 'scripting'. > > -- > Cecil Westerhof > Senior Software Engineer > LinkedIn:http://www.linkedin.com/in/cecilwesterhof
From: Cecil Westerhof on 19 Dec 2009 16:27 "joswig(a)corporate-world.lisp.de" <joswig(a)lisp.de> writes: > That's a good choice. > > CLISP, an implementation of Common Lisp ;-) , should be quite useful > for that. > It requires relatively little memory, has a byte code compiler and > has useful support for 'scripting'. I was thinking to switch to sbcl in the near future. Is clisp better as sbcl for scripting, or is there not a big difference? -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
From: joswig on 19 Dec 2009 16:50
On 19 Dez., 22:27, Cecil Westerhof <Ce...(a)decebal.nl> wrote: > "jos...(a)corporate-world.lisp.de" <jos...(a)lisp.de> writes: > > That's a good choice. > > > CLISP, an implementation of Common Lisp ;-) , should be quite useful > > for that. > > It requires relatively little memory, has a byte code compiler and > > has useful support for 'scripting'. > > I was thinking to switch to sbcl in the near future. Is clisp better as > sbcl for scripting, or is there not a big difference? Depends on what 'scripting' is. You might want to scan the manuals of CLISP and SBCL for built-in capabilities that are useful for you. > > -- > Cecil Westerhof > Senior Software Engineer > LinkedIn:http://www.linkedin.com/in/cecilwesterhof |