[racket] require error

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Oct 18 11:06:32 EDT 2011

[adding back the list again].

I'm not sure what is going on exactly, but it looks like it might be a
bad interaction between racket/base and eopl. Here's a smaller pair of
files that illustrates the problem:

green.rkt:
(module green eopl)

Another file (any file):

#lang eopl
(require racket/base)
(require "green.rkt")

Running the latter file produces the problem.

While we wait for someone to fix/address the issue, Marco, I think
that you can probably avoid the problem by not requiring racket/base.
Or, if you do need something from there, using an only-in or requiring
some other, smaller library should let you work around the problem.

hth,
Robby

On Tue, Oct 18, 2011 at 9:53 AM, Marco Morazan <morazanm at gmail.com> wrote:
> I've tried to reduce the rather large files I've been given.
>
> green.rkt:
> (module green eopl
>  (provide dummy)
>  (provide numfuncts)
>  (provide get-dummy)
>  (provide mutate-dummy!)
>
>  (define dummy 10)
>  (define (get-dummy) dummy)
>  (define numfuncts -1)
>  (define (mutate-dummy! x) (set! dummy x)) )
>
> test-require.rkt:
> #lang eopl
> (require scheme/base)
> (require "green.rkt")
>
> (define numfs numfuncts)
> (define (crazy x) (* dummy x))
>
> test-require produces the following error:
>
>  #%module-begin: bad syntax in: (#%module-begin (#%require
> scheme/base) (#%require "green.rkt") (define-values (numfs) numfuncts)
> (define-values (crazy) (lambda (x) (#%app * dummy x))))
>
> If I comment out the first require everything works fine as long as
> functions in racket/base are not used. That is:
>
> test-require.rkt:
> #lang eopl
> (require scheme/base)
> (require "green.rkt")
>
> (define numfs numfuncts)
> (define (crazy x) (* dummy x))
> (define (f x) (build-vector 10 (lambda (i) (* i x))))
>
> Throws the following error:
>
> #%module-begin: bad syntax in: (#%module-begin (#%require scheme/base)
> (#%require "green.rkt") (define-values (numfs) numfuncts)
> (define-values (crazy) (lambda (x) (#%app * dummy x))) (define-values
> (f) (lambda (x) (#%app build-vector (quote 10) (lambda (i) (#%app * i
> x))))))
>
> Version info:
>
> Welcome to DrRacket, version 5.1.3 [3m].
> Language: eopl; memory limit: 128 MB.
>
>
>
> On Tue, Oct 18, 2011 at 10:41 AM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> This sounds like a bug in #lang eopl (at least in the error message
>> reporting), but this program is still not enough to actually reproduce
>> the problem. For me, for example, this works fine:
>>
>> #lang eopl
>> (require racket/base)
>> (require racket/list)
>>
>> So it isn't just having two requires.
>>
>> Robby
>>
>> On Tue, Oct 18, 2011 at 9:37 AM, Marco Morazan <morazanm at gmail.com> wrote:
>>> I see where there are some problems.
>>>
>>> First, I see they are attempting to mutate variables defined in a
>>> required module. This, I believe, can be fixed by exporting mutating
>>> functions from the required module.
>>>
>>> Second, they want to have multiple require statements like:
>>>
>>> #lang eopl
>>> (require racket/base)
>>> (require "green.rkt")
>>>
>>> <code>
>>>
>>> The above produces the following error:
>>>
>>>  #%module-begin: bad syntax in: (#%module-begin (#%require
>>> racket/base) (#%require "green.rkt") ...
>>>
>>> Commenting out the first require statement causes an expected error on
>>> a function in racket/base:
>>>
>>>  expand: unbound identifier in module in: build-vector
>>>
>>> Is this enough context to point me in the right direction?
>>>
>>>
>>>
>>> On Tue, Oct 18, 2011 at 9:23 AM, Robby Findler
>>> <robby at eecs.northwestern.edu> wrote:
>>>> I think we'll probably need some more context to say what is going on.
>>>> Can you post a complete program that has that symptom?
>>>>
>>>> Robby
>>>>
>>>> On Tue, Oct 18, 2011 at 8:16 AM, Marco Morazan <morazanm at gmail.com> wrote:
>>>>> I'm at a loss with this error. Can anyone provide some insight?
>>>>>
>>>>> So, I have the following (in a file named green.rkt):
>>>>> (module green ...
>>>>>  (provide expr)
>>>>>  (provide program)
>>>>>  ...
>>>>>  ;(provide num-functs)
>>>>>
>>>>>  <a bunch of definitions including definitions for expr, program,
>>>>> num-functs, and everything in the ...>  )
>>>>>
>>>>> In a different file I have:
>>>>>
>>>>> (require "green.rkt")
>>>>>
>>>>> If as above, I comment out (provide num-functs) I get the following error:
>>>>>
>>>>>     expand: unbound identifier in module in: num-functs
>>>>>
>>>>> This makes sense since I have not provided num-functs.
>>>>>
>>>>> If I uncomment it I get the following error:
>>>>>
>>>>>  #%module-begin: bad syntax in: (#%module-begin (#%require
>>>>> scheme/base) (#%require "green.rkt") (define-syntaxes (prog)
>>>>> (let-values (((cert) (#%app syntax-local-certifier (quote #t)))) ....
>>>>>
>>>>> There is no problem reported with any other of my provide statements
>>>>> which resolved all other of my errors of type 1 above (i.e., expand).
>>>>>
>>>>> Any suggestions?
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Marco
>>>>> _________________________________________________
>>>>>  For list-related administrative tasks:
>>>>>  http://lists.racket-lang.org/listinfo/users
>>>>>
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> Cheers,
>>>
>>> Marco
>>>
>>
>
>
>
> --
>
> Cheers,
>
> Marco
>



Posted on the users mailing list.