[racket] typed racket, eval and enter!
Hi jao,
I'm excited that you're trying to provide better TR support in Geiser.
I think this transcript shows the more basic problem:
[samth at huor:~ plt] cat > x.rkt
#lang typed/racket
(define: j : Number 10)
(define: k : Number 20)
[samth at huor:~ plt] r
Welcome to Racket v6.0.0.1.
-> (compile-enforce-module-constants #f)
-> (enter! "x.rkt")
"x.rkt"> j
- : Number
10
"x.rkt"> k
- : Number
20
"x.rkt"> (define: jk1 : Number (+ j k))
"x.rkt"> jk1
- : Number
30
"x.rkt"> (eval '(define: jk2 : Number (+ j k)))
"x.rkt"> jk2
; readline-input:11:0: Type Checker: untyped identifier jk2
; in: jk2
; [,bt for context]
The type checker doesn't have any idea about anything named `jk2`,
because it never got put in the type environment. The entry points
for Typed Racket, roughly, are `#%module-begin` and
`#%top-interaction` and neither of them are involved here.
But if we use `#%top-interaction`:
"x.rkt"> (eval '(#%top-interaction . (define: jk2 : Number (+ j k))))
"x.rkt"> jk2
- : Number
30
"x.rkt">
It all works magically.
Hope that's enough to get things working for you.
Sam
On Fri, Jan 3, 2014 at 7:36 PM, Jose A. Ortega Ruiz <jao at gnu.org> wrote:
>
> Hi,
>
> While trying to provide good support to typed racket in Geiser (an Emacs
> interface to Racket and Guile) i've run into a problem similar to the
> following one.
>
> Using plain racket 5.3.6 (in a terminal, no Emacs or Geiser involved
> here), and the following file:
>
> ------ test.rkt --------
> #lang typed/racket
>
> (define: j : Number 10)
> (define: k : Number 20)
> ------ eof test.rkt -----
>
> here's a very short racket session illustrating the problem:
>
> [/home/jao/tmp]$ racket
> Welcome to Racket v5.3.6.
> > (compile-enforce-module-constants #f)
> > (require "test.rkt")
> > (eval '(define: jk : Number (+ j k)) (module->namespace '(file "test.rkt")))
> > (eval 'jk (module->namespace '(file "test.rkt")))
> 20
> > (enter! "test.rkt")
> > j
> - : Number
> 10
> > k
> - : Number
> 10
> > jk
> stdin::214: Type Checker: untyped identifier jk
> in: jk
> >
>
> As you can see, one can eval forms in a typed namespace without problem,
> but entering the namespace and asking for a value defined via eval
> produces an error.
>
> Am i doing or expecting something wrong?
>
> Thanks in advance,
> jao
> --
> If a listener nods his head when you're explaining your program, wake
> him up.
> - Alan Perlis, Epigrams in Programing
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users