Re: [VOTE] Scalar Type Hints
| From: | Pavel Kouřil | Date: | Sun, 08 Feb 2015 09:49:53 +0000 |
| Subject: | Re: [VOTE] Scalar Type Hints | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82130@lists.php.net to get a copy of this message | ||
On Sat, Feb 7, 2015 at 11:11 PM, Andrea Faulds <ajf@ajf.me> wrote:
> Hi,
>
>> On 7 Feb 2015, at 22:03, Pavel Kouřil <pajousek@gmail.com> wrote:
>>
>>
>> Yeah, but you say in the RFC that "With this approach, an argument is
>> only accepted if its type is exactly the same as the parameter." when
>> speaking about C# and Java - which is NOT true.
>
> C# and Java aren’t really considered weakly-typed. Technically they’re not “fully
> strict” I guess, but if you were to give example of strictly-typed languages, you’d probably
> include C# and Java in that list - so I did.
C# and Java definitely aren't weakly typed. I never said they are
though? Also, is there a real difference between strict and strong?
Because C# refers to itself as a strongly typed, but you use "strict
typing" everytime you speak about strong typing?
>
> It might be somewhat misleading. Really, what’s “weak” and what’s “strict” is
> rather subjective: C is sometimes considered weak, sometimes strict. I’d say it’s more
> “weak” because all sorts of definitely wrong conversions are allowed implicitly and merely
> generate warnings. C# and Java are more careful here, so I’d say they’re “strict” even
> though I suppose they do have a degree of weak typing.
>
>> Also, there's no need to mention
>> float -> int, because that one is definitely wrong. But for the int
>> (and long, etc) -> float (and double) - how do the languages you
>> mentioned in the RFC handle that conversion?
>
> From Microsoft’s documentation that you linked, it sounds like they just always convert and
> never error, so you’d get data loss in some cases (just like you do in PHP with an explicit cast).
>
> I am familiar with other languages, I just disagree with their approach.
>
It's not somewhat misleading, it's 100% misleading - because you state
that it acts like in Java and C#, but it doesn't. Also, are there any
strongly typed language that implement strong/strict typing the way
you want to do it in PHP?
>> And as I said myself
>> multiple times in the past, the declare syntax IS just ugly (and
>> changing how code works by writing one line is an ugly principle as
>> well, IMHO). :(
>
> I prefer this approach to the inconsistency the other approaches suggested thus far lead to.
>
The thing is, you cannot please everyone. When you try to please
anyone, you usally end up with something that has flaws for everyone
to some degree. :(