[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Trouble loading source file in csi

From: Peter Bex
Subject: Re: [Chicken-users] Trouble loading source file in csi
Date: Sun, 26 Aug 2012 22:01:34 +0200
User-agent: Mutt/

On Sat, Aug 25, 2012 at 02:47:33PM -0600, Matt Gushee wrote:
> > I am developing a chicken library, and attempting to perform some
> > rudimentary tests in csi as I go. However, when I try to load the file
> >
> >   (load "text-menu.scm")
> >
> > I get the following error:
> >
> > :   ; loading text-menu.scm ...
> > :
> > :    Error: history entry index out of range: 0
> >
> Apparently the problem was that I wrote '#' instead of '#f' in a couple of
> places. So the REPL did right to catch my error. I'd still be interested to
> know why the file would load without error (and seemingly function
> normally)

Hi Matt,

The reason it accepts this is that #n is special reader syntax in the
interpreter which means "give me the nth expression's result value".

$ csi -q
#;1> (+ 1 2)
#;2> (+ #1 7)
#;3> (+ #2 2)

So it's the number printed in the prompt, which can always be used
to recall the result value of the expression typed at that particular
prompt.  (this is also why the number doesn't increase when the
expression causes an error -- it never returned anything, so the
prompt's numbered expression got no value)

A lone hash in Chicken seems to return the previous expression's
value (I didn't know about this either):

#;4> #

This is of course also documented.
for more info.  I hope this clarifies this "strange" behaviour :)

"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

reply via email to

[Prev in Thread] Current Thread [Next in Thread]