geiser-users
[Top][All Lists]
Advanced

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

Re: [Geiser-users] geiser-eval-last-sexp not working for Racket


From: Jose A. Ortega Ruiz
Subject: Re: [Geiser-users] geiser-eval-last-sexp not working for Racket
Date: Sat, 29 Dec 2012 20:29:18 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

On Sat, Dec 29 2012, Limbo Peng wrote:

> Hi,
>
> I've encountered a issue when using "geiser-eval-last-sexp" - the
> steps to reproduce the issue are:
>
> 1. create a new file (say "/tmp/mytest.rkt")
> 2. run-racket
> 3. write some code in the file, for example:
>
>     #lang racket
>     (provide my-sane-var)
>     (define my-sane-var 1234) ;; cursor here
>
> 4. invoke "geiser-eval-last-sexp" by pressing C-x C-e
> 5. check in REPL - nothing gets eval'ed!?

It does, but not in the namespace the REPL is in by default.  The
evaluation takes place inside the file's module, not in the top level,
and, therefore, the variable is not visible unless you require the
module, or put all definitions at the top level.

If you save the file and switch to the REPL with C-u C-c C-z (note the
C-u), Geiser REPL will enter the module (you'll see the prompt change),
and the definitions will be visible.

>     => my-sane-var: undefined;
>     =>     cannot reference undefined identifier
>
> However, if I change the "#lang racket" to "(require racket)", and
> repeat step 4-5, the expression gets eval'ed as expected?

When you remove the #lang directive, the file doesn't define a module
anymore, and the definitions are at the top-level.  That's the reason
the variable is then visible.

> Is it a bug of geiser or something?

It's just the way modules and namespaces work in Geiser and Racket.  The
sections of the Geiser manual on its 'modus operandi':

  http://geiser.nongnu.org/geiser_1.html#Modus-operandi

REPL context:

  http://geiser.nongnu.org/geiser_3.html#Switching-context

and the end of:

  http://geiser.nongnu.org/geiser_4.html#The-source-and-the-REPL

(you can also read the manual inside Emacs in its texinfo version).

HTH,
jao
-- 
Spend the afternoon. You can't take it with you.
  -Annie Dillard, author (b. 1945)



reply via email to

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