I'm having an issue with BSL. I want to divide my code into separate auxiliary files and use
(require "auxiliary-function.rkt")
at the beginning to import the separated code into the definitions area. However it doesn't work as supposed. Though no explicit error given, it seems like that that DrRacket simply doesn't see the code in the separate file and all I see is the error
<auxiliary-function-name>: this function is not defined
Apparently,
(provide x)
is not included in BSL. I've read the manual and this answer but it’s still not clear how to make this work. Is this even possible in BSL?
Thanks!
BSL is not for you. If you know how to manage modules, I recommend you use full-fledged Racket.
If you wish to create auxiliary libraries, I recommend you develop them in full Racket, provide the identifiers you need, use htdp/error to formulate error messages, and 'require' will then work.
Note that if you're doing this for a course this strategy might not be accepted for a submission.
What I have done for some of my own projects is a pattern like this:
Have one file written in plain Racket, called
"provide.rkt"
, like this:Then you can use this to either provide specific functions or provide all definitions from a file.
For providing specific functions
In your "library" BSL file, you can require provide into it like this, and use that to provide the specific function(s) you want:
And finally, in your "main" BSL file, you can require the library like this:
For providing all definitions from a file
In your "library" BSL file, you can require provide into it and use that to provide everything:
Then in your "main" BSL file, you can require the library and get all of the definitions: