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

Nick Treleaven nick at geany.org
Sat Jul 30 15:43:38 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.

Unless it was special cased, that would fall back to top level 
imports if the modules named didn't exist in std.math. (Following 
usual rules for with). So when seeing `with... import` you'd have 
to be aware of that. Maybe other syntax would be clearer.


More information about the Digitalmars-d mailing list