max() in phobos, and English logic operators

Bill Baxter wbaxter at gmail.com
Thu Nov 9 08:35:22 PST 2006


David Qualls wrote:
> == Quote from Bill Baxter (dnewsgroup at billbaxter.com)'s article
> 
> 
>>But my point was just that the extra information is not
> 
> necessary for
> 
>>the macro version.  The intended meaning of max(x,0) is clear
> 
> enough to
> 
>>the reader, so the compiler should be able to handle it without
>>complaining, too.
>>--bb
> 
> 
> EXACTLY!  I also think you (mostly) nailed it with
> 
> 
>>About signed types, I think
>>    auto c = max(a,b)
>>should pick the same type for c that the compiler would pick for
>>    auto c = a+b;
> 
> 
> except I don't think max(10U , -1) should return -1 cast to an
> unsigned!

Oof.  No it should not.  But the macro would fail there too.  At least 
in D, (10U<-1) evaluates to true.


--bb



More information about the Digitalmars-d-learn mailing list