Hey Jakob,

On Tue, Mar 17, 2020, 02:27 Jakob Givoni <ja...@givoni.dk> wrote:

> On Mon, Mar 16, 2020 at 9:31 AM Marco Pivetta <ocram...@gmail.com> wrote:
> > What happens if you have an expression that throws?
> >
> > class Foo
> > {
> >     public $a;
> >     public $b;
> >     public $c;
> > }
> >
> > $instance = new Foo();
> >
> > function iThrow() {
> >     throw new \Exception();
> > }
> >
> > try {
> >     $foo ->[
> >         a = 'a',
> >         b = iThrow(),
> >         c = 'c',
> >     ];
> > } catch (\Throwable $e) {
> >     var_export($foo); // ???
> > }
>
> Hi Marco!
> Trivial question - let's see what happens:
>
> Just replace COPA with the old syntax and run it:
>
> try {
>     $foo->a = 'a';
>     $foo->b = iThrow();
>     $foo->x = 'c';
> } catch (\Throwable $e) {
>     var_export($foo); // ???
> }
>
> Result:
> Foo::__set_state(array(
>    'a' => 'a',
>    'b' => NULL,
>    'c' => NULL,
> ))
>
> So the first property will be set, the rest will be left as they were.
>

That kinda makes the entire feature quite useless/uninteresting to me: if a
this does is desugaring into a set of assignments, then I'm not sure what
its advantage is.

I was kinda hoping for an atomic state mutation across multiple fields,
heh...

>

Reply via email to