1 matches bool, 2 matches long
Maxim Fomin
maxim at maxim-fomin.ru
Fri Apr 26 01:14:10 PDT 2013
On Friday, 26 April 2013 at 08:00:28 UTC, Walter Bright wrote:
> On 4/26/2013 12:07 AM, Maxim Fomin wrote:
>> Regarding bool type as integer type is C atavism and should be
>> abandoned.
>
> There's a very loooong history of 0 being regarded as false and
> 1 as true - it goes well beyond C.
This should be irrelevant in case of long parameter. Such
conversion should not be in the language (like feature of array
to pointer conversion and function to pointer to function
conversion is present in C but not in D).
>> This leads to comic sitatuation presented in the thread when
>> changing literal to
>> lvalue or using different enums changes overloading matching.
>
> Yet I showed an analogous example where different overloads
> were selected based on a different integer value.
>
> There's no getting away from having to pay attention when
> declaring different overloads of a function. In the original
> example, the correct solution is to provide a foo(int). I'd be
> suspicious of any code that only had overloads on just bool and
> long - it doesn't make sense.
I argue the correct solution is to call integer function with
integer parameter when integer value is passed. Adjusting to
buggy compiler behavior isn't a good idea.
More information about the Digitalmars-d
mailing list