[gambit-list] REPL behaviour

Marc Feeley feeley at iro.umontreal.ca
Tue Mar 1 14:39:40 EST 2011

On 2011-03-01, at 2:20 PM, spir wrote:

> Hello,
> Totally new to Gambit-Scheme (and mostly new to Lisp/Scheme in general).
> I just installed Gambit-C, precisely for learning, and started to try the REPL. 
> Here is an example of what I get:
> =======================
> spir at d:~$ gsi
> Gambit v4.2.8
>> (define var 9)
>> (display var)
> 9>
> (define var2 10)
>> (define (double x) (+ x x))
>> (double 3)
> 6
>> (display double)
> #<procedure #2 double>> (define var3 11)
> =======================
> 0) No feedback at all for 'define'. (OK)

That is correct.  Some special forms (such as define and set!) and procedures (such as display and write-char) don't return anything, so nothing is printed by the REPL.  Actually, their evaluation at the REPL returns the void object, but the REPL does not print anything when it gets the void object.

> 1) New prompt not separated from output of previous command.

That's because you used "display", which does not output a newline.  You'd get the same behaviour with "write" and "print".  You could use "println" which adds a newline, or better yet, use "pp" which will pretty print the output and is shorter to type:

> (define (double x) (+ x x))
> (pp 9)
> (pp double)
(lambda (x) (+ x x))

> 2) Key-presses of <enter> do not generate new prompt.

That's the traditional behaviour of Scheme REPLs.  I tried Bigloo, Chicken, MzScheme, MIT-Scheme and Scheme48, and only Scheme48 displays a new prompt when an empty line is entered.  I'm not sure what is the "best" thing to do in such a case, but at least it is intended.


More information about the Gambit-list mailing list