Re: What do we need strict scalar type hints for?

From: Date: Mon, 02 Feb 2015 17:55:22 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1 2  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Mon, Feb 2, 2015 at 7:47 PM, Paul Dragoonis <[email protected]> wrote:

> Hi Dmitry,
>
> It's preferred to have flexible scalars, that way we can interchange
> between a numerical string or an integer.
>
> Over defining on such things loses the powerfulness of PHP. So scalar
> typehints are detrimental rather than useful. Saying something is a scalar
> or not, is useful however! :)
>
> A use case would be where scalar type hints are detrimental are:
>
> I implement an API that returns integers for entity ids, like 2,3,4,5,6.
> and my web-frontend handles this fine because it's a scalar. Then, you want
> to convert entity ids to  UUID. This would break your entire web frontend
> application since it's no longer "integer" whereas the concept of $id is
> good enough.
>

I don't think this is a good case where strict type hinting is really
helpful.


>
> Did this make sense?
>
> TL;DR - I am against such proposals.
>

Now, I'm more interested in opinions of people who like strict type hinting.
I prefer weak hints, that follow standard conversion rules, but may be good
arguments may change my mind.

Thanks. Dmitry.


>
> Many thanks,
> Paul
>
>
>
>
>
> On Mon, Feb 2, 2015 at 9:12 AM, Dmitry Stogov <[email protected]> wrote:
>
>> hi,
>>
>> could you please write down few use cases, when strict scalar type hints
>> are really useful.
>>
>> Thanks. Dmitry.
>>
>
>


Thread (78 messages)

« previous php.internals (#81622) next »