Re: [PHP-DEV] Inline switch as alternative to nested inline conditional

2019-10-15 Thread Michał Brzuchalski
Hi David,

I'm interested in this feature this is called switch expression and is on
my list of RFC to process after Object Initializer RFC.

I have an RFC in draft for that and planning to finish it soon together
with some syntax optimisations - you can see it at
https://wiki.php.net/rfc/switch-expression-and-statement-improvement

Cheers,
Michał Brzuchalski

śr., 16 paź 2019, 03:46 użytkownik David Rodrigues 
napisał:

> Hello. I like to suggests a discussion about a FR to make possible to
> inline switch, as an alternative to nested inline conditionals.
>
> $value = switch (expr()) {
> case A1: return A2;
> case B1: return B2;
> default: return C;
> }
>
> Instead of:
>
> $expr = expr();
> $value = $expr == A1 ? A2 : ( $expr == B1 ? B2 : C );
>
> Just a discussion to check what do you think.
>
> --
> David Rodrigues
>


[PHP-DEV] Re: Inline switch as alternative to nested inline conditional

2019-10-15 Thread Mark Randall

On 16/10/2019 02:46, David Rodrigues wrote:

Hello. I like to suggests a discussion about a FR to make possible to
inline switch, as an alternative to nested inline conditionals.


```
http://www.php.net/unsub.php



[PHP-DEV] Inline switch as alternative to nested inline conditional

2019-10-15 Thread David Rodrigues
Hello. I like to suggests a discussion about a FR to make possible to
inline switch, as an alternative to nested inline conditionals.

$value = switch (expr()) {
case A1: return A2;
case B1: return B2;
default: return C;
}

Instead of:

$expr = expr();
$value = $expr == A1 ? A2 : ( $expr == B1 ? B2 : C );

Just a discussion to check what do you think.

-- 
David Rodrigues


Re: [PHP-DEV] [VOTE] Reclassifying engine warnings

2019-10-15 Thread Christoph M. Becker
On 15.10.2019 at 10:27, Gert wrote:

> I may be a bit late to this party, but will the promotion to error
> exception of illegal offsets also happen for using resources as array
> keys? These currently produce a notice, and are then casted to an
> integer: https://3v4l.org/cQ8hf
> Or will the behaviour of that remain the same?

Only objects and arrays will throw; resources are promoted from E_NOTICE
to E_WARNING.

--
Christoph M. Becker

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [VOTE] Reclassifying engine warnings

2019-10-15 Thread Gert
I may be a bit late to this party, but will the promotion to error
exception of illegal offsets also happen for using resources as array
keys? These currently produce a notice, and are then casted to an
integer: https://3v4l.org/cQ8hf
Or will the behaviour of that remain the same?

On Fri, 11 Oct 2019 at 18:16, Claude Pache  wrote:
>
>
>
> > Le 11 oct. 2019 à 11:12, Olumide Samson  a écrit :
> >
> > On Fri, Oct 11, 2019, 9:29 AM Benjamin Morel 
> > wrote:
> >
> >>>
> >>> As people have expressed interest in hearing about direct technical
> >>> benefits that these kinds of changes have ... let me give you an example
> >>> that came up yesterday.
> >>
> >>
> >>
> >> Too bad this example comes after the vote has been made, and failed.
> >> This would be a very strong argument in favour of using exceptions
> >> everywhere in the next major version: codebase cleanup, room for more
> >> optimization.
> >>
> >> Nikita, please fork PHP, we'll follow you ;-)
> >>
> >> — Benjamin
> >>
> >
> > I think I'm always available to contribute to a fork of a better PHP, coz I
> > love the syntax not the garbages included in the current one.
>
> If you’re seeking a fork of PHP that wilfully breaks BC for the sake of 
> cleanup and optimisation, you should seriously consider Hack. Although I 
> don’t know whether they’ve already removed support of the appalling implicit 
> initialisation of  variables to `null`, or of the dreadful backtick operator, 
> you’ll be delighted to learn that they’re on the process of removing 
> references, PHP arrays (in favour of Hack arrays and collections), and even 
> that little pesky ` ;-)
>
> https://hhvm.com/blog/2019/02/11/hhvm-4.0.0.html 
> 
>
> Enjoy. (But not with me: our company does not have the budget to migrate 30 
> Mo of code without counting external libraries.)
>
> —Claude
>
>

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php