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

From: Date: Thu, 05 Feb 2015 18:50:25 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

> On 5 Feb 2015, at 06:52, Dmitry Stogov <[email protected]> wrote:
> 
> I completely agree.
> Strict typing doesn't fit into PHP. It was already told thousand times.

Seems to work rather well in practice, so long as it’s optional.

> Also, the only really useful case for "strict typing" is the ability to catch
> mistakes in user apps.
> However, this ability is really limited. Implementing "Design by Contact" approach
> may be much smarter.

It’s not that limited. I caught two different bugs in my app simply by adding strict types.

Strict typing, crucially, allows the catching of errors ahead of time, too. You can’t do that with
weak typing, because it depends on the value, not the type. And you don’t know the value from
reading the source code.

--
Andrea Faulds
http://ajf.me/






Thread (78 messages)

« previous php.internals (#81956) next »