KeV
KeV

Reputation: 2891

R5RS "provide" issues

I made a program in Racket and now I have to change my code to R5RS. But I immediately get errors.

I had the following code in Racket :

#lang racket
(provide a-function)
(define (a-function)
  ; Do something
  #t)
(define a-variable #t)

Then I changed it to R5RS :

#lang r5rs
(#%provide a-function)
(define (a-function)
  ; Do something
  #t)
(define a-variable #t)

Now the problem is that when I run this simple code and try to call the procedure "a-function" it tells me a-function: undefined; cannot reference an identifier before its definition

I noticed that this problem is only with procedures, the variable "a-variable" is known but no procedures are known...

EDIT : I tried to disguise a procedure as a variable to see if he knows that procedure, but then I get the same error.

#lang r5rs
(#%provide a-function)
(define a-function (lambda (x y) (+ x y)))

I searched a lot and I think the problem must be that I'm still merging my Racket code to R5RS so certain files are still in Racket, other files are in R5RS and that this is causing troubles for a reason I don't understand (it shouldn't be a problem...)

EDIT : I reconstructed the problem as easy as possible :

R5RS file "a.rkt" :

#lang r5rs
(#%provide makePosition)
(define (makePosition x y)
  (cons x y))

Racket file :

#lang racket
(require "a.rkt")
(makePosition 20 10)

When running the Racket file this gives rise to the error "undefined identifier ...".

According to one of my teachers this is a Racket bug.

Upvotes: 2

Views: 149

Answers (1)

Sorawee Porncharoenwase
Sorawee Porncharoenwase

Reputation: 6502

For the last program (makePosition), note that R5RS is case-insensitive, so makePosition is normalized to makeposition. Racket world, however, is case-sensitive, so makePosition doesn't exist; makeposition does.

For other programs, I really couldn't reproduce the problem. Did you change anything when you posted the question to StackOverflow?

Upvotes: 0

Related Questions