Conditional Pure?

Michel Fortin michel.fortin at michelf.com
Sat Jan 22 18:58:08 PST 2011


On 2011-01-22 21:34:52 -0500, %u <wfunction at hotmail.com> said:

>>> Any ideas on how we might be able to get that to work?
>> @optional_tag(is(T == int) || is(T == long)), const)
> 
> Ouch... a bit less pretty than I'd hoped (the underscore makes it a bit ugly
> IMHO). Does it really need to be a tag, though? Why not just:
>    optional(const, is(T == int) || is(T == long))
> ?

If you're trying to make it pretty, I'd suggest this:

	template func(T) {
		const pure if (is(T == int) || is(T == long)) {
			void func(T);
		}
	}

>From what I know of the front end, I'm of the opinion that it'd be much 
easier to implement conditional attributes in the front end that way.

But things gets messed up once you consider the 'static' attribute. :-(

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list