D import idiom compilation time

Martin Tschierschke mt at smartdolphin.de
Tue Jan 8 15:18:03 UTC 2019


On Tuesday, 8 January 2019 at 14:28:47 UTC, H. S. Teoh wrote:
> On Tue, Jan 08, 2019 at 02:13:21PM +0000, Martin Tschierschke 
> via Digitalmars-d wrote:
>> [...]
>
> Not true. This works:
>
> 	void main() {
> 		// N.B.: local imports
> 		import std.array;
> 		import std.algorithm;
> 		import std.conv;
> 		import std.stdio;
>
> 		// N.B.: UFCS chaining
> 		"abcdef".map!(e => cast(int) (e - 'a'))
> 		        .filter!(e => e < 4)
> 			.map!(e => cast(dchar) (e + 'm'))
> 			.to!string
> 			.writeln;
> 	}
>
> To state more accurately what Adam said, UFCS is considered for 
> *module-level* symbols. Meaning, the requirement is applied at 
> the site of definition (it has to be at the top *level* in the 
> module where it's defined) rather than the site of import 
> (which can be in a local *scope*).
>
>
> T
OK. Thank you!

With "real local import" I was referring to the "new import 
idiom" in this thread, provided by  localimport.dub.pm

mt.



More information about the Digitalmars-d mailing list