[racket] Typed-Racket: provide and mutable variables

From: Wayne Iba (iba at westmont.edu)
Date: Sun Oct 26 17:59:59 EDT 2014

I've started porting code to typed/racket.  One module is now typed and
used in an untyped module that has not yet been ported.  In the untyped
module, I call a function (provided by the typed module) that updates
provided variables but the values observed in the untyped module do not
reflect the changes.

For example,
testtyped.rkt:
#lang typed/racket
(provide *name* get-name set-name)
(define: *name" : String "initial")
(define: (get-name) : String *name*)
(define: (set-name! [new-name : String]) : Void (set! *name* new-name))

and then in testuntyped.rkt:
#lang racket
(require "testtyped.rkt")
*name*
(set-name! "new-name")
*name*
(get-name)

The result of running testuntyped.rkt is two "initial"s and one
"new-name".  If I change the lang of testtyped.rkt to just racket (and
remove the type annotations), running testuntyped gives me the expected one
"initial" and two "new-name"s.

If I change the lang of testuntyped.rkt to typed/racket, it works as I
wanted.  But until I can port everything, ... I don't think creating
getters for all my variables is an option.  Thanks in advance for any
suggestions.  --Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20141026/a213048d/attachment.html>

Posted on the users mailing list.