Arc Forumnew | comments | leaders | submitlogin
Racket submodules (
2 points by rocketnia 2352 days ago | 1 comment

2 points by rocketnia 2352 days ago | link


This was brought up on LtU recently:



Racket's new submodule design is geared so that a piece of Racket code can be structured so that people can not only import it as a library, but also run its tests, run it as an application, or use it as a language. Essentially, this gives you multiple verbs you can use when you see a Racket file laying around. :-p

Where before a Racket module was essentially some imports, definitions, side effects, and exports, now it will also have child modules, which can be accessed without executing the parent. Certain child module names like "main" and "test" are special-cased by language.

Submodules can be imported without importing their parent:

  (require (submod "cake.rkt" extras))


I don't think this has significant consequences for Arc, except as a potential tool in maintaining the Racket versions of Arc.

If someone finds this an inspiring example of language design, that's their prerogative. :-p I do like its simplicity and practicality, but I'd hesitate to say it's a very seamless design, thanks to hardcoded names like "main". It has a convention-over-configuration flavor to it in that respect.

I wonder if Racket is dynamic enough to have supported this kind of thing as a sublanguage, but I doubt it. Racket kinda has first-class namespaces, but modules--and names imported from modules--are difficult or impossible to manipulate programmatically, and this doesn't do anything to ameliorate that.