Re: [RFC] Scalar Type Hints
| From: | Andrea Faulds | Date: | Fri, 02 Jan 2015 00:18:06 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80074@lists.php.net to get a copy of this message | ||
> On 1 Jan 2015, at 23:58, Stanislav Malyshev <smalyshev@gmail.com> wrote:
>
>> ability to check correct usage with tooling. I'd also like to point out
>> that Hack uses a strict type scheme and it seems to work well there (though
>
> Java uses strict typing too. And Perl has no typing whatsoever. So what?
> How bringing an example of one language that does what you want is an
> argument for PHP to do that? There are examples of languages doing
> practically anything imaginable.
To add to what Stas says: C, in fact, has weak parameter typing. A function taking a long long can
be passed a char, or a double, or even a pointer. Now, there’s a good case to be made that C’s
weak parameter typing is bad. But that’s mostly because C will let you shoot yourself in the foot
and overflow bounds, corrupt memory or cause a segfault. PHP doesn’t have these issues though, so
that argument doesn’t really apply.
By the way, “weak parameter typing” sounds like a good name for this. Makes more sense than
“non-strict” or “casting”.
--
Andrea Faulds
http://ajf.me/