On Tuesday, September 11, 2012 15:14:43 Jonathan M Davis wrote:
> If you're going to use a cast, then use one where you give the type
> explicitly. Using typeof(return) is just asking for it when the compiler is
> clearly already having issues with the return type.

And actually, in all honesty, I see no reason to use auto here. If you know 
what the return type is supposed to be (e.g. double), then just use double. 
Casting where it's unnecessary is just begging for bugs.

Based on Namespace's posts in this thread, I get the impression that what he 
wanted was that the return type would be either int or double depending on the 
value returned - i.e. he was trying to get dynamic typing - which doesn't 
work, because D is a static language. If that's what he wants, he needs to use 
Variant, and casting and the like is going to do him no good. auto was the 
wrong choice in the first place.

- Jonathan M Davis

Reply via email to