0

I'm trying to use geiser-mode in emacs to run racket code. I've been able to install geiser-mode and launched racket.

Yet when I run a definition twice I got the following error. this name was defined previously and cannot be re-defined

here is simple example

 (define  a (* 1 4))
 a

run twice

In the debugger

#a: this name was defined previously and cannot be re-defined
#in: a
DJJ
  • 2,481
  • 2
  • 28
  • 53

1 Answers1

1

racket appears to behave differently in a file and the REPL. This file will throw an error:

#lang racket

(define a 5)
(define a 6)

And this REPL session will not:

> (define a 5)
> a
5
> (define a 6)
> a
6

The behavior is because of the way modules work. When working in a file, there is an implicit module. Once the symbol a has been defined in that module another symbol with the same name cannot be defined within that module. The REPL simply expands forms without all the ceremony of modules.

ben rudgers
  • 3,647
  • 2
  • 20
  • 32