RE: [PHP-DEV] Syntactical change to Scalar Type Hints RFC
| From: | Zeev Suraski | Date: | Sun, 08 Feb 2015 20:33:59 +0000 |
| Subject: | RE: [PHP-DEV] Syntactical change to Scalar Type Hints RFC | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82168@lists.php.net to get a copy of this message | ||
FWIW, while I think strict types - stricter than even strict languages -
don't belong in PHP, this syntax is clearly a step up from declare(), which
was definitely not intended for this purpose.
Zeev
> -----Original Message-----
> From: Andrea Faulds [mailto:ajf@ajf.me]
> Sent: Sunday, February 08, 2015 9:45 PM
> To: PHP Internals
> Subject: [PHP-DEV] Syntactical change to Scalar Type Hints RFC
>
> Hi,
>
> I’m posting this in a new thread since people might (reasonably) be
> ignoring
> further responses to the [VOTE] thread.
>
> I’m considering a small change to the Scalar Type Hints RFC, specifically
> about syntax. Quite a few people have said they don’t like the declare()
> syntax, and it’s easy to see why. It’s rather verbose, it has all the
> quirks of
> declare() (such as block syntax, not respecting scope), and it’s rather
> ugly.
>
> Instead, I’m wondering if the following might be better:
>
> <?php strict
>
> Which would be used like so:
>
> <?php strict
>
> function foobar(): int {
> return 1.0; // error!
> }
>
> It’d be a per-file directive, so there’d be zero mixing of modes within
> one file,
> and you’d avoid the quirks of declare().
>
> It’s also a lot shorter, and it resembles Hack’s syntax:
>
> <?hh // strict
>
> Of course, changing this would mean restarting the vote, but it’s only
> been
> three days, we’re less than a quarter of the way through voting.
>
> Thoughts? Thanks!
>
> (By the way, I’d appreciate it if this thread didn’t turn into yet another
> discussion of how and whether scalar type hints are a bad/good idea. We
> already have at least four threads on that subject. I’m just considering a
> specific change of syntax.)
>
> --
> Andrea Faulds
> http://ajf.me/
>
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List To unsubscribe,
> visit:
> http://www.php.net/unsub.php