Re: [VOTE][RFC] Coercive Scalar Type Hints
| From: | Levi Morrison | Date: | Sat, 14 Mar 2015 04:32:34 +0000 |
| Subject: | Re: [VOTE][RFC] Coercive Scalar Type Hints | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-84759@lists.php.net to get a copy of this message | ||
On Fri, Mar 13, 2015 at 10:31 PM, Levi Morrison <levim@php.net> wrote:
> On Fri, Mar 13, 2015 at 8:50 PM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>> On Mar 14, 2015, at 13:37, Levi Morrison <levim@php.net> wrote:
>>> It seems that
float -> bool is always disallowed. If
>>> I am correct
>>> int -> bool is permitted for all values (not just 0
>>> and 1), which
>>> means that floats which can be converted to integers without dataloss
>>> should also be permitted to be booleans. If a specific float can be
>>> converted to an int, and all ints can be converted to booleans, then
>>> the transitive property should hold for that float to a bool.
>>
>> The problem there is what does "without dataloss" mean? At which precision do you
>> consider there to be no dataloss?
>
> Ah, I reread part of the RFC. It appears float -> int is
> unchanged
> from current. This only confuses me more, though. If int -> float is
> permitted, and float -> int is permitted, I do not understand why
> float -> bool is not permitted.
>
> Can someone clarify this?
I apologize; my hands didn't keep up with my brain. I meant that if
int -> bool is permitted, and float -> int is permitted, then by
transitive property I would expect float -> bool to be permitted.
Can someone clarify why this is not the case? The RFC does not appear
to justify this behavior (that I can find, anyway).