This is all a bit moot anyway, the RFC proposal is for warnings or notices
on implicit casts only.
I'm not a voting member for RFCs so my opinion is mere food for thought,
nonetheless my two cents is that:
a) The proposal relies on a premise that an implicit cast of (non-zero
fractional) float to
On 06/02/2021 14:47, Christian Schneider wrote:
I'm sure there is a lot of code which takes user input and uses (int) casts to
ensure they are dealing with integers.
There is also intval() as an alternative but my guess would be that real world
code uses 50% (int) and 50% intval() to do this.
Am 06.02.2021 um 01:17 schrieb Benjamin Morel :
> Could we at least fix the odd cases where the cast is definitely a failure?
> Like:
>
> (int) 1e60; // 0
> (int) "foo"; // 0
Are you talking about the constant values 1e60 and "foo"? If not then please
don't add a warning (or worse).
I'm sure t
On 5 February 2021 23:45:59 GMT, David Gebler wrote:
>I still think a warning is too high an error level for this and would
>favour a notice or deprecation, were it to be done at all.
I'd just like to point out that a deprecation notice implies (or should imply!)
that the behaviour will be comp
On Fri, Feb 5, 2021 at 6:46 PM David Gebler wrote:
> > Floats (doubles) can accurately represent all integers up to 2⁵³, so
> there
> > is no inaccuracy in this range; the result from round() or floor() could
> > therefore be safely passed to (int) even if the cast operator checked for
> a
> > 0
On Sat, 6 Feb 2021 at 00:46, David Gebler wrote:
> Generating a warning on explicit casts of (non-integer) floats to int
> would IMO make no sense at all, it would put PHP at odds with other major
> languages such as C, Python and Java and go against normal, reasonable
> expectations of how a pro
> Floats (doubles) can accurately represent all integers up to 2⁵³, so there
> is no inaccuracy in this range; the result from round() or floor() could
> therefore be safely passed to (int) even if the cast operator checked for
a
> 0 fractional part, which is what I'm advocating for.
Generating a
On Fri, 5 Feb 2021 at 11:56, AllenJB wrote:
> (And after checking the manual, I'd also note here that round() also
> returns a float, so how exactly does your example here work? Is it only
> OK to explictly cast a float that's the return value of a function? Or
> only explictly cast a float if th
On 04/02/2021 17:54, Benjamin Morel wrote:
On Thu, 4 Feb 2021 at 17:05, G. P. B. wrote:
Greetings internal,
I'm proposing a new RFC which would warn when an implicit conversion
from float to int occurs.
The draft is currently located on GitHub:
https://github.com/Girgias/float-int-warning/
f
On Thu, 4 Feb 2021 at 17:55, Benjamin Morel
wrote:
> On Thu, 4 Feb 2021 at 17:05, G. P. B. wrote:
>
>> Greetings internal,
>>
>> I'm proposing a new RFC which would warn when an implicit conversion
>> from float to int occurs.
>>
>> The draft is currently located on GitHub:
>> https://github.com
> Except that example is ambiguous. Specifically, which is more logical,
to truncate it to 3 or round it up to 4? It probably depends heavily on
your context. Implicitly doing one or the other can result in surprises.
I disagree this is ambiguous. The integral portion of a float is what it
is,
On Thu, Feb 4, 2021, at 12:06 PM, David Gebler wrote:
> If this were to be done, my gut feeling is a notice would be preferable to
> a warning, particularly as there must be many scripts which would suddenly
> start churning out warnings for this proposed change which might/probably
> ignore lower
On 04/02/2021 17:54, Benjamin Morel wrote:
$age = $_GET['age']; // '25.75'
$x = (int) $foo; // I'd expect a warning, not a silent conversion to 25
If we want to make explicit casts "fussy", that would be a much bigger
change. Right now, the following are all valid, with no warnings, even
tho
If this were to be done, my gut feeling is a notice would be preferable to
a warning, particularly as there must be many scripts which would suddenly
start churning out warnings for this proposed change which might/probably
ignore lower error levels and emitting a warning for a previously common
sc
On Thu, 4 Feb 2021 at 17:05, G. P. B. wrote:
> Greetings internal,
>
> I'm proposing a new RFC which would warn when an implicit conversion
> from float to int occurs.
>
> The draft is currently located on GitHub:
> https://github.com/Girgias/float-int-warning/
> for ease of commenting/providing
Greetings internal,
I'm proposing a new RFC which would warn when an implicit conversion
from float to int occurs.
The draft is currently located on GitHub:
https://github.com/Girgias/float-int-warning/
for ease of commenting/providing changes to it.
The official discussion phase wouldn't start
16 matches
Mail list logo