2021-03-26 23:00 GMT+01:00, Rowan Tommins <rowan.coll...@gmail.com>: > 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. I wonder if it would provide a way to > implement the "data-flow" or "expression context" exception handling I > was discussing on a different thread recently. > > Looking at my previous example: > > try { > $foo = doSomething() + $bar; > } > catch ( SomeException $e ) { > $foo = $bar; > } > > Would become something like this: > > $foo = match($temp = doSomething()) { > exception SomeException => 0, > default => $temp > } + $bar;
You can't catch the value of $temp in the match-case? $foo = $bar + match (doSomething()) { $temp => $temp, exception SomeException => 0 }; Olle -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php