Re: [PHP-DEV] Making "match" catch exceptions

2021-03-27 Thread Olle Härstedt
2021-03-27 15:30 GMT+01:00, Rowan Tommins : > On 26/03/2021 22:58, Olle Härstedt wrote: >> You can't catch the value of $temp in the match-case? >> >> $foo = $bar + match (doSomething()) { >>$temp => $temp, >>exception SomeException => 0 >> }; > > > $temp doesn't have an o

Re: [PHP-DEV] Making "match" catch exceptions

2021-03-27 Thread Rowan Tommins
On 26/03/2021 22:58, Olle Härstedt wrote: You can't catch the value of $temp in the match-case? $foo = $bar + match (doSomething()) { $temp => $temp, exception SomeException => 0 }; $temp doesn't have an outside value, it was an inline assignment to capture the value

Re: [PHP-DEV] Making "match" catch exceptions

2021-03-26 Thread Olle Härstedt
2021-03-26 23:00 GMT+01:00, Rowan Tommins : > On 26/03/2021 16:45, Olle Härstedt wrote: >> That made me think of a recent >> extension to OCaml which makes it possible to catch exceptions in a >> match-expressions (here's one blog post about it: >> https://blog.janestreet.com/pattern-matching-and-e

Re: [PHP-DEV] Making "match" catch exceptions

2021-03-26 Thread Rowan Tommins
On 26/03/2021 16:45, Olle Härstedt wrote: That made me think of a recent extension to OCaml which makes it possible to catch exceptions in a match-expressions (here's one blog post about it: https://blog.janestreet.com/pattern-matching-and-exception-handling-unite/). That's an interesting idea

[PHP-DEV] Making "match" catch exceptions

2021-03-26 Thread Olle Härstedt
Hi, Someone mentioned that they prefer lambdas over try-catch blocks, which surprised me, since try-catch is completely idiomatic in both PHP and OCaml (Haskell I don't know). That made me think of a recent extension to OCaml which makes it possible to catch exceptions in a match-expressions (here