Symbol lookup rules and imports

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Dec 2 15:20:59 PST 2014


On Tue, 2 Dec 2014 14:00:09 -0800
"H. S. Teoh via Digitalmars-d" <digitalmars-d at puremagic.com> wrote:

> 	// mymod.d
> 	module mymod;
> 	struct S {
> 		// Now everyone is happy, right...?
> 		import std.range : isInputRange;
> 
> 		void method(R)(R range)
> 			if (isInputRange!R)
> 		{
> 		}
> 	}
ah, how i HAET that! importing std.traits in module scope just to have
preconditions in templates drives me mad. i want to be able to insert
import statements before that `if`! and i want that imports to not
affect template body too.

sure, i can do hacks with lambdas here, but i want the code to be
easily readable -- that's why we have that cool `if` conditions there!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141203/c0b8acf5/attachment.sig>


More information about the Digitalmars-d mailing list