Re: Silent Types
| From: | M. W. Moe | Date: | Wed, 04 Sep 2019 18:01:30 +0000 |
| Subject: | Re: Silent Types | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106860@lists.php.net to get a copy of this message | ||
Hello,
this would be very possible constant with the actual without breaking BC
allow declare var = value : type; -> throws if assignment + type fails
the grammar context is exactly the same than a function return.
Best.
On Wed, Sep 4, 2019 at 10:18 AM Andreas Hennings <andreas@dqxtech.net>
wrote:
> On Wed, 4 Sep 2019 at 09:22, Lynn <kjarli@gmail.com> wrote:
> >
> > Note that this behavior would require making some decisions whether or
> not
> > in the future this opt-in behavior should change when a default value is
> > given, such as with C# and type inference when declaring a variable,
> based
> > on its assigned value.
>
> I think this would too easily lead to mistakes.
> E.g. if in a git commit, "$x = 5.6;" is replaced with "$x = 5;" or "$x
> = '5.6';", then would a reviewer notice that this implicitly changes
> the type?
> Also, what if the initialization is inside an if branch? Later the
> if/else gets reordered, or one of the conditional branches gets
> removed, and the variable changes its type?
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>