DIP10005: Dependency-Carrying Declarations is now available for community feedback

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 14 09:32:10 PST 2016


On Wed, Dec 14, 2016 at 05:24:42PM +0000, Andrej Mitrovic via Digitalmars-d wrote:
> On Wednesday, 14 December 2016 at 17:09:44 UTC, ketmar wrote:
> > > bool equal(R1, R2) : std.range, std.traits
> > > if (isInputRange!R1 && isInputRange!R2 && isArray!R2)
> > > { ... }
> > 
> > breaks possible selective import. if both modules exports some symbol,
> > we will need to selectively import and/or rename it.
> 
> Not necessarily. The first colon is the only special case, afterwards you
> can use all forms of imports:
> 
> > > bool equal(R1, R2) : std.range : isInputRange, Trait = std.traits
> > > if (isInputRange!R1 && isInputRange!R2 && Trait.isArray!R2)
> > > { ... }

What about:

	/* Showing full declaration just for context */
	bool myFunc(R1, R2)(R1 r1, R2 r2)
	import {
		std.range : isInputRange,
		std.traits : isNum = isNumeric
	}
	if (isInputRange!R1 && isInputRange!R2 &&
	    isNum!(ElementType!R1))
	in { assert(someCondition!R1); }
	out(result) { assert(result == expectedResult(...)); }
	body
	{
		...
	}


T

-- 
EMACS = Extremely Massive And Cumbersome System


More information about the Digitalmars-d mailing list