Manfredi
Manfredi

Reputation: 172

Include modules in racket

I created a module (game.rkt) in Racket in which there is my game logic; in this file I define several variables, functions, threads...

I need to embed that module inside another one (gui.rkt) and start the game (game.rkt) from gui.rkt.

How do I do that?

Upvotes: 1

Views: 94

Answers (1)

Greg Hendershott
Greg Hendershott

Reputation: 16250

  • gui.rkt: You need to provide the definitions you want other modules to be able to use. Definitions aren't visible outside the module, by default. If you've defined functions foo and bar that you want to provide: (provide foo bar).

  • game.rkt: (require "gui.rkt").

This assumes files are in the same directory.

For more details see the Guide sections about require and provide. Both have a number of options -- Racket's module system is one of its strongest features -- but the simple case is simple.

Upvotes: 3

Related Questions