D import idiom compilation time
Jonathan Marler
johnnymarler at gmail.com
Wed Jan 9 22:39:58 UTC 2019
On Tuesday, 8 January 2019 at 14:40:47 UTC, Johan Engelen wrote:
> On Tuesday, 8 January 2019 at 13:39:48 UTC, JN wrote:
>> On Monday, 7 January 2019 at 21:50:20 UTC, Andrei Alexandrescu
>> wrote:
>>> This is pretty awesome.
>>>
>>> Since the implementation would (initially at least) be
>>> private, the presence of "from" in documentation would be
>>> awkward. So I suggest the glorious hack:
>>
>> I am probably in minority here, or I am misunderstand the
>> purpose of this feature, but wouldn't such stuff be better put
>> somewhere around the compiler/frontend rather than in the
>> library with compile-time magic?
>
> FYI: at the end of last year Eyal (Weka) and Andrei (and me a
> little bit) have been discussing lazy importing (full import)
> of symbols by the compiler. We hope to have a student work on
> this.
> Indeed I agree with you: the compiler could do (some of) this
> stuff, and because the rewards seem large it makes sense to
> indeed have the compiler do it.
>
> -Johan
Make sure whoever works on it is aware of this:
https://github.com/marler8997/dlangfeatures#lazy-imports
To summarize, there's no way to make normal imports lazy (i.e.
"import foo;"). However we can make the following lazy by default:
1. static imports (static import std.typecons;)
2. selective imports (import std.typecons: isBigEndian;)
3. aliased imports (import t = std.typecons;)
I had a partial implementation for lazy imports, but Walter never
reviewed my other pull requests so I never pushed it.
More information about the Digitalmars-d
mailing list