January 07, 2014
On 01/07/2014 05:20 PM, Andrei Alexandrescu wrote:
> On 1/7/14 3:25 AM, monarch_dodra wrote:
>> Given that you *probably* imported "foo" with the plan to *use* one of
>> its functions, you'll encounter an unqualified call sooner rather than
>> later, and any "win" will promptly be lost.
>
> It's not a one- or two-levels win, it's a transitive win. An unqualified
> call in one implementation would trigger only one level of import.
>
> That said I agree it's suboptimal, but it's a net improvement in the
> compiler that requires zero changes to source code. According to Walter
> it would also get rid of some forward declarations issues.
>
>
> Andrei
>

Without introducing new ones?

The problem with getting rid of some forward declarations issues in the past has been that some new ones were often introduced due to the analysis order changing in ad-hoc ways.

What is the status of getting rid of _all_ forward declarations issues except those in a precisely specified set of uninterpretable usages?

E.g. I have no precise image of how arbitrary forward referencing of enum members is actually supposed to work in a consistent way without base type annotation.
August 04, 2014
On Monday, 6 January 2014 at 07:02:03 UTC, Andrei Alexandrescu wrote:
> Yah, but modules transitively imported in foo and bar need not be loaded eagerly. That's where the win comes from. Took me a while to figure.
>
> Andrei

Yes, it would help in certain cases (writeln doesn't have template constraints), but we should still use more static and scoped selective imports to reduce coupling.
Otherwise we can't improve on a quite common case.

import foo_dep, bar_dep;

void foo(T)(T) if(isSomeFoo!T) {}
void bar(T)(T) if(isSomeBar!T) {}

When using foo the compiler will have to import bar's dependencies and vice versa. Refactoring the imports gets rid of this problem.

import foo_dep : isSomeFoo;
static import bar_dep;

void foo(T)(T) if(isSomeFoo!T) { import foo_dep; /*..*/ }
void bar(T)(T) if(bar_dep.isSomeBar!T) { import bar_dep : someBar; /*..*/ }
1 2 3 4 5 6 7 8 9 10
Next ›   Last »