I wish the require
is not optimized for non-prefix-in
and non-only-in
.
Currently, it’s so easy to write (require racket/string)
but that causes compatibility issues when we want to add a new function to racket/string
Maybe a better API should be (require (all-from-in racket/string))
? Similar to import * from racket/string
Like, it’s OK if you want everything, but it should be explicit, and if you do that, we don’t guarantee that there won’t be compatibility issues
Also hope that Rhombus will have .
. Qualified import is great.
@sorawee Thanks for mentioning this, I like this idea and I’m changing my lang’s require
accordingly.
Yeah. Honestly I like java’s approach of one line per imported symbol, as long as I don’t have to write those lines by hand.
I use only-in
very consistently, and sometimes it means I end up with quite a lot of listed imports in every file. I’ve been thinking of changing over to an approach where:
One file in the codebase defines some macros that expand to
require
forms. (To be a little fancier, these could be require transformers or even a whole#lang
.)Many of the other files in the codebase just use those macros to require everything.
This way, most of the files wouldn’t just have a few lines of imports, but the codebase as a whole would still be meticulous about what it depends on from other codebases.