Why can't Racket find my module?

I have a very simple module with one export, in the file "m.rkt"

#lang racket
(module m racket
  (provide dec)
  (define (dec n)
    (- n 1)))

and another module in the file "n.rkt" that uses it

#lang racket
(module n racket
  (require "m.rkt")
  (define (id x)
    (+ 1 (dec x))))

In REPL, I am trying to load this second module

Welcome to Racket v6.0.1.
> (current-load-relative-directory "h:\\tmp")
> (require "n.rkt")
h:\tmp\n.rkt:8:10: dec: unbound identifier in module
  in: dec

It seems that the two module expressions are just fine, but they cannot allow export decfrom "m.rkt". Any idea what I'm doing wrong?

Update: Commenting out the language selection syntax #lang racketin both files makes things work correctly. According to section 6.2 of the Racket Guide, it #lang racketis an abbreviation for declaring a module, which is why my forms (module ...)declared submodules. Live and learn ...

+4
source share
1

( )

#lang . 6.2 , #lang , (...) . ...

+3

Source: https://habr.com/ru/post/1544237/


All Articles