Hi,
newbie question this! I am using clisp-2.41. If I paste this at the
prompt I get what you expect:
[1]> (= (+ 1 2) 3)
T
Now I've tried putting several of these together and pasteing those:
(= (+ 1 2) 3)
(= (+ 1 2) 3)
(= (+ 1 2) 3)
(= (+ 1 2) 3)
(= (+ 1 2) 3)
The result I've got is:
[2]> (= (+ 1 2) 3)
T(= (+ 1 2) 3)
[3]> ((= (+ 1 2) 3)
(= (+ 1 2) 3)
(= (+ 1 2) 3)
)
*** - EVAL: (= (+ 1 2) 3) is not a function name; try using a symbol
instead
The following restarts are available:
USE-VALUE :R1 You may input a value to be used instead.
ABORT :R2 ABORT
Break 1 [4]>
What am I doing wrong? And why is it re-writing this incorrectly? Can
you not paste commands from a text file?
Any help will be appreciated!
In article <·······················@q5g2000prf.googlegroups.com>,
"webmasterATflymagnetic.com" <·········@flymagnetic.com> wrote:
> Hi,
>
> newbie question this! I am using clisp-2.41. If I paste this at the
> prompt I get what you expect:
>
> [1]> (= (+ 1 2) 3)
> T
>
> Now I've tried putting several of these together and pasteing those:
>
> (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> (= (+ 1 2) 3)
>
> The result I've got is:
>
> [2]> (= (+ 1 2) 3)
> T(= (+ 1 2) 3)
>
> [3]> ((= (+ 1 2) 3)
> (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> )
>
> *** - EVAL: (= (+ 1 2) 3) is not a function name; try using a symbol
> instead
> The following restarts are available:
> USE-VALUE :R1 You may input a value to be used instead.
> ABORT :R2 ABORT
> Break 1 [4]>
>
> What am I doing wrong? And why is it re-writing this incorrectly? Can
> you not paste commands from a text file?
I think you're seeing the consequences of the way the REPL performs raw
input, which allows fancy input editing, but doesn't get things right if
you type ahead by pasting lots of input.
>
> Any help will be appreciated!
If you want to execute multiple expressions in sequence, you need to use
PROGN:
(progn (= (+ 1 2) 3)
(= (+ 1 2) 3)
...)
You can't just put them in a list, since the first thing in a list is
required to be an operator to be invoked (or a lambda expression), not
an expression to be evaluated.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
On Oct 14, 6:26 pm, Barry Margolin <······@alum.mit.edu> wrote:
> In article <·······················@q5g2000prf.googlegroups.com>,
>
>
>
> "webmasterATflymagnetic.com" <·········@flymagnetic.com> wrote:
> > Hi,
>
> > newbie question this! I am using clisp-2.41. If I paste this at the
> > prompt I get what you expect:
>
> > [1]> (= (+ 1 2) 3)
> > T
>
> > Now I've tried putting several of these together and pasteing those:
>
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
>
> > The result I've got is:
>
> > [2]> (= (+ 1 2) 3)
> > T(= (+ 1 2) 3)
>
> > [3]> ((= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > )
>
> > *** - EVAL: (= (+ 1 2) 3) is not a function name; try using a symbol
> > instead
> > The following restarts are available:
> > USE-VALUE :R1 You may input a value to be used instead.
> > ABORT :R2 ABORT
> > Break 1 [4]>
>
> > What am I doing wrong? And why is it re-writing this incorrectly? Can
> > you not paste commands from a text file?
>
> I think you're seeing the consequences of the way the REPL performs raw
> input, which allows fancy input editing, but doesn't get things right if
> you type ahead by pasting lots of input.
>
>
>
> > Any help will be appreciated!
>
> If you want to execute multiple expressions in sequence, you need to use
> PROGN:
>
> (progn (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> ...)
>
Ah, penny's dropped a little. I can see the sense in this. So the
issue is with the REPL system. I noticed if I did (load "filename") it
worked fine, but that seems to be a bit clunky (having said that, you
would do the same with a Unix script file).
Thanks for the response, that's helped a lot. I know the whole (Lisp)
world says Lisp is wonderful and you can't get better. I just want to
put enough effort in to get to the point where I can see what all the
fuss is about. I'll keep plodding on...
Cheers!
On Oct 14, 4:05 pm, "webmasterATflymagnetic.com"
<·········@flymagnetic.com> wrote:
> Thanks for the response, that's helped a lot. I know the whole (Lisp)
> world says Lisp is wonderful and you can't get better. I just want to
> put enough effort in to get to the point where I can see what all the
> fuss is about. I'll keep plodding on...
>
> Cheers!
maybe it's an issue with some REPLs. In my Scheme implementation it
returns multiple values as expected.
anyway, the REPL is a wonderful exploratory tool, but you quickly grow
old of typing and redefining things all the time and will likely type
your programs to a file anyway and just test the definitions in the
REPL.
Better yet, you could learn to use Emacs and type your program to a
buffer and interactively send definitions to the REPL with a
keystroke...
On 2007-10-14 15:05:51 -0400, "webmasterATflymagnetic.com"
<·········@flymagnetic.com> said:
> I noticed if I did (load "filename") it
> worked fine, but that seems to be a bit clunky (having said that, you
> would do the same with a Unix script file).
Of course you now also see why most people who use lisp regularly, do
so from an editor that has simple keyboard commands that allow the
loading and/or compilation of individual forms, selected blocks of text
(i.e., multiple forms), or whole files, right from an editor window.
The usual reccommendations here are one of the commercial IDEs (some
with quite usable free trial versions) or emacs with slime. CLISP has
GNU readline, which is better than a plain terminal interface, but much
less than emacs/slime or the free lispworks trial version have to
offer. BTW, if you do try lispworks, make sure to get Edi Weitz's
lispworks add-ons.
From: Kent M Pitman
Subject: Re: Please explain this REPL behaviour
Date:
Message-ID: <uodf14h50.fsf@nhplace.com>
Barry Margolin <······@alum.mit.edu> writes:
> > [3]> ((= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > )
> >
> > *** - EVAL: (= (+ 1 2) 3) is not a function name; try using a symbol
> > instead
[...]
> If you want to execute multiple expressions in sequence, you need to use
> PROGN:
>
> (progn (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> ...)
>
> You can't just put them in a list, since the first thing in a list is
> required to be an operator to be invoked (or a lambda expression), not
> an expression to be evaluated.
Heh. Well, probably doing
(list (= (+ 1 2) 3)
(= (+ 1 2) 3)
...)
is what they want, since absent doing this, you can't see the results
of any but the last when PROGN is used.
Or, given that it's the same expression each time.
(let ((form '(= (+ 1 2) 3)))
(dotimes (i 3) (print (eval form))))
not that it's going to do a lot different since there are no side effects
than
(let ((result (= (+ 1 2) 3)))
(dotimes (i 3) (print result)))
But in some other case, perhaps
(dolist (form '((= (+ 1 2) 3) (= (+ 1 2) 3.0)))
(format t "~&~S => ~S~%" form (eval form)))
would do better.
Thanks to everyone who responded! The little gems of information
(different gems from different people) are all helping to build a
picture of how the mind in the Lisp world thinks. In particular the
note below caught my eye -- I was only querying the strange response
of the REPL, but I can see how at any opportunity abstraction is a key
ability.
Everyone's replies have been equally valuable.
Thanks again!!
On Oct 14, 8:42 pm, Kent M Pitman <······@nhplace.com> wrote:
> Barry Margolin <······@alum.mit.edu> writes:
> > > [3]> ((= (+ 1 2) 3)
> > > (= (+ 1 2) 3)
> > > (= (+ 1 2) 3)
> > > )
>
> > > *** - EVAL: (= (+ 1 2) 3) is not a function name; try using a symbol
> > > instead
> [...]
> > If you want to execute multiple expressions in sequence, you need to use
> > PROGN:
>
> > (progn (= (+ 1 2) 3)
> > (= (+ 1 2) 3)
> > ...)
>
> > You can't just put them in a list, since the first thing in a list is
> > required to be an operator to be invoked (or a lambda expression), not
> > an expression to be evaluated.
>
> Heh. Well, probably doing
>
> (list (= (+ 1 2) 3)
> (= (+ 1 2) 3)
> ...)
>
> is what they want, since absent doing this, you can't see the results
> of any but the last when PROGN is used.
>
> Or, given that it's the same expression each time.
>
> (let ((form '(= (+ 1 2) 3)))
> (dotimes (i 3) (print (eval form))))
>
> not that it's going to do a lot different since there are no side effects
> than
>
> (let ((result (= (+ 1 2) 3)))
> (dotimes (i 3) (print result)))
>
> But in some other case, perhaps
>
> (dolist (form '((= (+ 1 2) 3) (= (+ 1 2) 3.0)))
> (format t "~&~S => ~S~%" form (eval form)))
>
> would do better.
From: Don Geddis
Subject: Re: Please explain this REPL behaviour
Date:
Message-ID: <87abqizifq.fsf@geddis.org>
"webmasterATflymagnetic.com" <·········@flymagnetic.com> wrote on Mon, 15 Oct 2007:
> Everyone's replies have been equally valuable.
What kind of equal? EQ? EQL? EQUAL? EQUALP?
_______________________________________________________________________________
Don Geddis http://don.geddis.org/ ···@geddis.org
Give a man a match and he'll be warm for a minute, but set him on fire and
he'll be warm for the rest of his life. -- Paul Foley on comp.lang.lisp