%u:

> might turn out a bit unreadable. And, furthermore, I'd *like* to be able to 
> say
> something like "this method returns a shared const value iff the given type 
> is int
> or long" but this won't work with const() or shared() because of their syntax 
> (you
> can't say const(is(T == int))). Any ideas on how we might be able to get that 
> to work?

@optional_tag(is(T == int) || is(T == long)), const)


> Oh, and while on the note of const, here's a somewhat unrelated concern: I've
> noticed that code like this:
> 
> static const int* addressOf(ref int x) { return &x; }
> 
> is *very* tricky and misleading, because it's declaring the method as const, 
> not
> the pointer. Would it be a bad idea to forbid const, pure, nothrow, and the 
> like
> from coming before the method name? That way it won't be ambiguous like this.

I and few other people have asked for this, I think there is one closed 
enhancement request on this in Bugzilla, but I think Walter closed it on the 
basis of uniformity in attribute syntax (and maybe compiler simplicity too).
Sometimes it's worth breaking uniformity if this avoids some troubles, 
especially if all this breakage does is creating some easy-to-fix compile-time 
errors. I think this is one of such cases.

Bye,
bearophile

Reply via email to