[Issue 1626] bool spec problem
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Oct 30 02:03:48 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1626
------- Comment #3 from matti.niemenmaa+dbugzilla at iki.fi 2007-10-30 04:03 -------
(In reply to comment #2)
> I think you miss the point
> if( 3 )
> {
> }
> works
> And in the spec:
> "Expression is evaluated and must have a type that can be converted to a
> boolean. If it's true the ThenStatement is transferred to"
>
> Notice: If it's *true* the ThenStatement is transferred to
> So what's *true*? I would think the evaluated result of the specific
> expression.
> And what type can have value *true*? bool is the answer.
Read "it" as "cast(bool)Expression". So, "if cast(bool)Expression is true". So,
of course it's bool.
> Therefore, the expression is not only a type that *can* be converted to a
> boolean, but also a type already be converted to a boolean. So the convertion
> here is implicitly.
Yes, it is a type which can be converted to a boolean, and yes, the conversion
is done implicitly. But no, it doesn't have to be implicitly convertible. An
explicit cast is implicitly inserted.
I'll leave this open now, so somebody with access to the doc can make of this
what they will, but I don't see the problem.
--
More information about the Digitalmars-d-bugs
mailing list