The `with` construct is good, but it could be great

FeepingCreature feepingcreature at gmail.com
Mon Aug 8 12:59:42 UTC 2022


On Wednesday, 20 July 2022 at 16:53:27 UTC, jmh530 wrote:
> On a recent bug report I suggested `with` work with `import` so 
> that you could do something like `with(std.math) import 
> constants, hardware;` that would be equivalent to `import 
> std.math.constants, std.math.hardware;`. That seems like a 
> natural extension.

What I supported in an old language is:

```
import std.math.(constants, hardware);
```

Which has the advantage of not falling back to a toplevel import 
if not found.
But I don't think I'll do that in my current language, because 
it's sort of a library smell if you need a page full of imports. 
Just `import std;`.


More information about the Digitalmars-d mailing list