DIP10005: Dependency-Carrying Declarations is now available for community feedback
Meta via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 20 09:55:00 PST 2016
On Tuesday, 20 December 2016 at 01:06:01 UTC, Andrei Alexandrescu
wrote:
> Pushed again, now with the syntax using "with" proposed by
> Hatem Oraby and others.
>
> https://github.com/dlang/DIPs/pull/51
>
> https://github.com/dlang/DIPs/blob/71bde077488b566fba7603de6095b45984d9294a/DIPs/DIP1005.md
>
>
> Andrei
"In addition, we propose the statement and declaration with
(import ImportList). ImportList is any syntactical construct
currently accepted by the import declaration. The with (import
ImportList) obeys the following rules:
- Inside any function, with (Import ImportList) is a statement
that introduces a scope. Inside the with, lookup considers the
import local to the declaration (similar to the current handling
of nested imports).
- Everywhere else, with (Import ImportList) is always a
declaration and does not introduce a new scope. Lookup of symbols
is the same as for the statement case."
I must've somehow missed this when reading through for the first
time after your changes as I thought this was a glaring omission.
Glad to see that this was covered as this rightly makes it
turtles all the way down. Actually, you could completely replace
import statements with this new construct, having the `import
std.range` at the top level replaced with a module-wide attribute
`with (import std.range):`. In that light my only real criticism
is that it's kind of redundant having both this new form *and*
local imports, and it's not clear which is better and why to a
new user.
More information about the Digitalmars-d
mailing list