POV-Ray : Newsgroups : povray.off-topic : That's got to be one of the stupider design choices I've seen : Re: That's got to be one of the stupider design choices I've seen Server Time
4 Sep 2024 11:19:26 EDT (-0400)
  Re: That's got to be one of the stupider design choices I've seen  
From: Darren New
Date: 21 Feb 2010 13:43:58
Message: <4b817eee$1@news.povray.org>
Warp wrote:
>> You have to actually say
>>    xyz(0.3f, 12u)
>> because doubles don't silently cast to floats and ints don't silently cast 

>   12 yes, but are you sure 0.3 can be converted from double to float without
> losing precision? 

Actually, the annoyance isn't the lack of precision. It's that a literal 
without a marking saying what kind of literal it is is assumed to be a 
specific type even when the compiler can trivially determine that that type 
is the wrong type.

Of course, that kind of goes along with not being able to overload on the 
return type of a function, so I guess it isn't too unexpected. Better would 
be to have a tag letter for every type of literal (e.g., f for float, d for 
double, etc) and if the tag isn't there, the literal is whatever type is 
needed for that expression. I think that would cause annoyance less often, 
with the down side that you might wind up with ambiguous expressions that 
are combinations of literals that you'd need to disambiguate on occasion. 
(Sort of like if you had { print("Hello") } and print() had an ASCII 
overload and a UTF-8 overload or something.)

-- 
Darren New, San Diego CA, USA (PST)
   The question in today's corporate environment is not
   so much "what color is your parachute?" as it is
   "what color is your nose?"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.