On 16 January 2015 01:41:55 GMT, Stanislav Malyshev <smalys...@gmail.com> wrote:
>> debate. I'm just claiming that `(int) $num` is more explicit, has no
>> BC breaks and should, IMMO, be the preferred choice.
>
>No, it should not be, and I just wrote two mails explaining why exactly
>it should not. Here's the third.
>
>> Sorry, but this is the syntax used by the manual to describe
>functions
>> usage, not the actual implementation. The manual can be updated. The
>
>Of course, we can rewrite the whole manual and the whole language. 

You're muddling two things here: changing the notation in the manual would 
require absolutely no changes to the language, as long as it used a 
self-consistent notation to describe the language's behaviour.

> The
>question is - why we should make such huge changes if we already have
>this meaning and it has been there for years and it always meant
>exactly
>that - coercive typing for scalars - and never meant anything else?

Those reasons have been given many times; in summary, to keep the syntax for 
coercive hints distinct from the syntax for strict hints, rather than the same 
syntax meaning one for scalars and the other for non-scalars.

>> implementation itself can't be changed after major version release.
>
>The manual is what people read and rely on. But there's a bigger issue
>that you keep ignoring - that the functions having scalar typed
>argument
>*are* coercive *right now*. You describe it as if it's a typo in the
>manual that can be fixed or something that happened by accident and
>nobody intended it. Nothing can be further from the truth - it's how
>weak typing has been always working in PHP.

Now you are talking about the existence of the feature, not the syntax. It's a 
good argument for including coercive typing if any type hints are added, but 
internal functions will not need to be changed based on userland syntax.

> You want new feature for
>your use case? Fine, but claiming existing syntax for it and saying "no
>problem we'd just rewrite the whole manual and disregard 20 years of
>PHP
>history" sounds like a bit too much to ask.

There is no existing syntax in the language for scalar type hints of any kind.

As for the manual, IIRC, there's already precedent for altering its conventions 
to match language features, when "callable" was introduced as a typehint; the 
manual previously used "callback" to annotate those parameters.

The manual also uses return type on the left, but I don't think anyone's 
arguing that decides the discussion on that syntax, which will probably 
actually put return types on the right. 
It's just a convention in the manual which doesn't actually match any existing 
PHP code, and can be changed with no compatibility issues whatsoever.

Regards,
-- 
Rowan Collins
[IMSoP]


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to