Syntactical change to Scalar Type Hints RFC
| From: | Andrea Faulds | Date: | Sun, 08 Feb 2015 19:44:44 +0000 |
| Subject: | Syntactical change to Scalar Type Hints RFC | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82162@lists.php.net to get a copy of this message | ||
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/