[racket] confusing error message: what is "lang:read.1"?

From: Matthew Butterick (mb at mbtype.com)
Date: Fri Aug 8 10:05:04 EDT 2014

FWIW this isn't a gratuitously perverse example. It's derived from the actual bug  I've encountered. I use `eval` in my Pollen system to handle dynamic rendering of pages delivered through the web server (don't panic, everyone — it's an approved use of `eval` [1])

I use the `dynamic-rerequire` to reload files that have changed since last render. In fact you added it at my request, as I was looking for a Racket function that approximated the Python `reload` function. [2]

For now I've worked around the bug — in test-case terms, I've changed this

;;; three.rkt
#lang racket

To this:

;;; three.rkt
#lang racket/base

But why that makes a difference, I'm not clear. 

[1] http://docs.racket-lang.org/web-server/faq.html
[2] http://lists.racket-lang.org/users/archive/2013-April/057530.html


On Aug 7, 2014, at 10:23 PM, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Wed, 6 Aug 2014 15:50:41 -0700, Matthew Butterick wrote:
>> Under certain circumstances, because of what I assume is a bug in my code, I 
>> get an error like this:
>> 
>>> define-values: assignment disallowed;
>>> cannot re-define a constant
>>>  constant: lang:read.1
>>>  in module: "/Users/mb/git/racket/racket/collects/racket/main.rkt"
>>>  context...:
>>>   (submod /Users/mb/git/racket/racket/collects/racket/main.rkt reader): 
>> [running body]
>> 
>> I understand how the "assignment disallowed" error arises. What I don't 
>> understand is the meaning of "lang:read.1" in this context. I'm guessing it has 
>> something to do with the #lang line (?) but ... the rest is hazy. 
> 
> The "lang:read" part is the name of a variable that appears in the
> macro expansion of the `racket` module's `reader` submodule. The ".1"
> part is because that variable is macro-introduced so that it is not
> directly accessible using the name `lang:read`.
> 
> The way that `dynamic-rerequire` and submodules interact here is
> unsatisfying. I think it's a collision between the way that
> `dynamic-rerequire` pulls from source and the use of
> `namespace-module-attach` within `make-base-namspace`, and I think that
> `dynamic-rerequire` needs to do something different, but I haven't yet
> sorted it out.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140808/add36d29/attachment.html>

Posted on the users mailing list.