Re: [RFC] Scalar Type Hints v0.2

From: Date: Wed, 14 Jan 2015 15:45:14 +0000
Subject: Re: [RFC] Scalar Type Hints v0.2
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-80470@lists.php.net to get a copy of this message
Andrea Faulds wrote on 14/01/2015 13:15:
Hi Thomas,
On 14 Jan 2015, at 13:04, Thomas Nunninger <thomas@nunninger.info> wrote: Sorry, if my mail was not clear. My point was: If I write a library in strict mode and someone else is using it from his non-strict mode, he can pass an integer to myFunc() without an error. If I use this integer in my library and hand it over to otherFunc() (in my library) this will fail as integer is not accepted for float. Or did I misunderstood the RFC and there is a casting of the integer to a float when calling myFunc()?
The value would be casted, yes. From the function author’s perspective, there’s no need to worry about strict vs. weak typing: in both cases, you get the type you asked for.
Perhaps it would be clearer if the RFC (and the documentation, if this is accepted) referred to the non-strict as something other than "weak". It makes it sound like only a weak check will be performed, and some values of the "wrong" type will be allowed through, when in reality you will always get exactly the type asked for. Maybe "coercive type-checking" would more accurately reflect the functionality? Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#80470) next »