proposed syntax change

Yigal Chripun yigal100 at gmail.com
Thu Aug 6 13:34:21 PDT 2009


Ary Borenszweig wrote:
> Adam D. Ruppe wrote:
>> On Thu, Aug 06, 2009 at 03:06:49PM -0400, Paul D. Anderson wrote:
>>> Oh wait...I think "//" is used elsewhere.
>>
>> Is this a joke?
> 
> No. When porting C, C++, Java or C# code just search "//" and replace it 
> with "--".
> 
> Oh wait... I think "--" is used elsewhere.

Why would I as a user want to have two ops that do the same thing?!
Python's solution for this is wrong IMHO since the problem is not with 
the op itself but rather with the way C handles numbers.

5 / 2 should always be the more precise FP division unless the compiler 
knows or is instructed to do otherwise.

int a = 5 / 2; // compiler knows to use integer division

auto b = 5 / 2; // b is double, FP division

auto c = cast(int)(5/2)); // compiler instructed to use integer division

auto d = floor(5 / 2); // FP division floored by a function to int

auto f = std.math.div(5, 2); // intristic that does integer division

what's the rationale of not doing the above, besides C compatibility?



More information about the Digitalmars-d mailing list