Re: Syntactical change to Scalar Type Hints RFC
| From: | Andrea Faulds | Date: | Sun, 08 Feb 2015 20:53:10 +0000 |
| Subject: | Re: Syntactical change to Scalar Type Hints RFC | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-82172@lists.php.net to get a copy of this message | ||
Hi François,
On 8 Feb 2015, at 20:43, François Laupretre <francois@tekwire.net> wrote:
>> De : Andrea Faulds [mailto:ajf@ajf.me]
>> 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().
>
> '<?php' is not a 'per-file' directive, as it can appear several times,
> and is not always the first item in a file.
>
> What would this mean :
>
> Lines of data
> ...
> <?php
> php code
> ?>
> Data
> <?php strict
> Code
> ...
>
> Would it be strict or not ? or will you interpret the first '<?php' only ? What is
> the syntax exactly ? Does it make 'strict' a reserved keyword ?
It doesn't make "strict" be reserved.
With regards to multiple blocks, there are a few possible approaches:
* First block affects subsequent blocks, only it can declare strictness (my favourite)
* Per-block
* Use of directive prevents use of end tags, and thus use of multiple blocks
I think the first makes the most sense. It's what namespaces do, after all.
Thanks.
--
Andrea Faulds
http://ajf.me/