From: Tamas K Papp on
On Fri, 04 Dec 2009 07:08:42 -0800, Pillsy wrote:

> On Dec 4, 5:34 am, Tamas K Papp <tkp...(a)gmail.com> wrote: [...]
>> I would appreciate if people could comment on the code.  It is nothing
>> complicated and runs fine, I just want to learn the idiomatic way to
>> use CL for scripting.
>
> You really like those TAGBODYs and GOs don't you? :)

Yes, guilty as charged :-) I started using TAGBODYs for certain
macros, and then they crept into my simple code too. At the moment I
don't think of this as a stylistic mistake (it seems to be the
clearest way to express what I am doing), but I am open to arguments.

>> For example, is line-by-line (see below) the recommended way to
>> redirect
>> a stream to a file?
>
> That's how I've always done it. I never even realized that READ-LINE had
> that second return value; that almost makes up for the way it mixes
> optional and keyword arguments. [...]

I was thinking about how READ-SEQUENCE could perhaps be more
efficient, with a preallocated buffer that I just reuse. But I guess
that a lot of buffering is done at the OS level already, so maybe
READ-LINE is not that bad. Anyhow, it doesn't matter for my purposes
at the moment.

Tamas


From: Pillsy on
On Dec 4, 11:02 am, Tamas K Papp <tkp...(a)gmail.com> wrote:
> On Fri, 04 Dec 2009 07:08:42 -0800, Pillsy wrote:

> > On Dec 4, 5:34 am, Tamas K Papp <tkp...(a)gmail.com> wrote: [...]

> >> I would appreciate if people could comment on the code.  It is nothing
> >> complicated and runs fine, I just want to learn the idiomatic way to
> >> use CL for scripting.

> > You really like those TAGBODYs and GOs don't you? :)

> Yes, guilty as charged :-) I started using TAGBODYs for certain
> macros, and then they crept into my simple code too.  At the moment I
> don't think of this as a stylistic mistake (it seems to be the
> clearest way to express what I am doing), but I am open to arguments.

I think they're at least as clear as the alternatives.

I eventually wound up writing a little library of functions and macros
for use in scripts (DO-LINES is one of them) and dumping a script-
oriented SBCL image with it and CL-PPCRE and the right command-line
options, for when I need to write scripts. But now I really want to
try out ECL....

Cheers,
Pillsy
From: fortunatus on
On Dec 4, 11:44 am, Pillsy <pillsb...(a)gmail.com> wrote:
> I eventually wound up writing a little library of functions and macros
> for use in scripts (DO-LINES is one of them) and dumping a script-
> oriented SBCL image with it and CL-PPCRE and the right command-line
> options, for when I need to write scripts.

Me too, probably we all do - my version of DO-LINES can either do
READs on each and bind variables, or provide line as a string, or
provide lines as a stream, and optionally require a match for lines to
process. It's easy enough to put WHENs in the body to do other
matches.

(with-each-line-do (in-stream
(&rest vars-to-read-from-line)


I also have a script writing macro that transfers command line
arguments into local binidings
From: fortunatus on
I'm not doing too well with the keyboard today! That previous post
was supposed to read:

Me too - my version of DO-LINES can either do READs on each and bind
variables, or provide line as a string, or provide lines as a stream,
and optionally require a match for lines to process. It's easy enough
to put WHENs in the body to do other matches.


(with-each-line-read (in-strm (val1 val2 ...)
:match "matchstring")
...)

or

(with-each-line-read (in-strm ()
:match "matchstring"
:linestring text-strg)
...)

etc.


I also have a script writing macro that transfers command line
arguments into local binidings


(define-script my-script ((arg1 "-flagForArg1") ...)
... )


So the command line looks like

SBCL -load <file> -eval (my-script) -flagForArg1 <arg1Value>
From: Juanjo on
On Dec 4, 4:37 pm, Tamas K Papp <tkp...(a)gmail.com> wrote:
> On Fri, 04 Dec 2009 07:20:07 -0800, fortunatus wrote:
> > You could replace the tagbody with simple LOOP and LOOP-FINSH, or you
> > could use the complex LOOP keywords like DO and WHILE.  But frankly I
> > find your TAGBODY and GO to be quite clear as it is, even probably more
> > clear than the complex loop keywords would be.  Otherwise I think your
> > code is great!
>
> > By the way, would you mind posting what you did for yourECLexec?
> > Thanks!
>
> > (loop
> >   :do (multiple-value-bind ... )
> >   :while line
> >   :do (if missing-new-line (...) (...))
>
> See this nice writeup:http://blog.s21g.com/articles/1649
>
> I just fired up anECL, and used
>
> (compile-file "savebody.lisp" :system-p t)
> (c:build-program "savebody" :lisp-files '("savebody.o"))
>
> but apparently you can do much more complex stuff.  And the whole
> executable is really small.  ECLjust rocks.

For more complex programs, the ASDF extensions are probably better:

http://ecls.sourceforge.net/new-manual/ch16.html

I am really happy that you are satisfied with it! It would be nice if
you could share your experience somewhere in the wiki, for instance
opening a page in the success stories section of the wiki

http://ecls.wikispaces.com/
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: 3 questions about arrays
Next: Is President Obama a Nice Guy?