Algorithms, term rewriting and compile time reflection

Low Functioning via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 23 09:58:46 PDT 2014


On Thursday, 23 October 2014 at 15:18:09 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 23 October 2014 at 13:57:03 UTC, Low Functioning 
> wrote:
>> How about a function returns a T', which is implicitly 
>> convertible to T, where T' has some enum "tags" attached to it.
>
> Why is implicit conversion a problem? To the compiler it would 
> just be another function call?

Not everything is generic, for one reason or another.

struct notimplicit(T) {
	T _x;
	enum fubared;
}

struct foo(T) {
	T _x;
	alias _x this;
	enum fubared;
}

unittest {
	notimplicit!int a;
	//int _a = a; //error

	foo!int b;
	int _b = b;
}

While it wouldn't matter for a fully generic pipeline, and you'd 
lose the fubared tag if you turned it back to the base type, it 
might be handy to propagate the fubared type while remaining 
compatible with the base.


More information about the Digitalmars-d mailing list