1 matches bool, 2 matches long
Jonathan M Davis
jmdavisProg at gmx.com
Sat Apr 27 17:34:33 PDT 2013
On Saturday, April 27, 2013 06:19:29 Maxim Fomin wrote:
> On Friday, 26 April 2013 at 21:34:44 UTC, Walter Bright wrote:
> > On 4/26/2013 1:59 PM, Diggory wrote:
> >> The actual value shouldn't be taken into
> >> account when determining which overload to call, only the type
> >> should matter,
> >
> > D has an interesting feature called VRP (value range
> > propagation), where implicit conversion very much depends on
>
> > the value. For example:
> Then perhaps ban VRP on arguments if it affects overloading?
No. The problem really isn't with VRP. The problem is the fact that D is
weakly typed with regards to bool. In virtually all cases, having VRP do it's
job is exactly what we want. It's just that in this one, weird things happen
because of the implicit conversion to bool which is of zero utility in this
case, because if that's what you wanted, you'd just use a boolean literal
rather than an integer one.
I really think that allowing the implicit conversion to bool is truly helpful
in only a small number of cases (e.g. arithmetic which wants to add 0 or 1
depending on the result of a boolean expression), and it clearly results in
behavior that most people don't expect in quite a few instances. The fact that
stuff like
auto b = false / true;
compiles is just downright bizarre.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list