# "or throw new" syntax

- Thread: https://externals.io/message/49569
- Original archive: https://news-web.php.net/php.internals/49569
- Started by Kalle Sommer Nielsen on 2010-09-05T12:19:16+00:00
- Messages: 2
- RFC: throw expression (Implemented (PHP 8.0)) — https://externals.io/rfc/throw_expression.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #49569 — Kalle Sommer Nielsen — 2010-09-05T12:19:16+00:00

URL: https://externals.io/message/49569#49569

Hi

Is there any reason for we don't support expressions like:

test() or throw new Exception('test() failed');


If no, is there any argument against supporting such a syntax in trunk?

-- 
regards,

Kalle Sommer Nielsen
kalle@php.net

---

## #49570 — Etienne Kneuss — 2010-09-05T12:30:35+00:00

URL: https://externals.io/message/49569#49570 · In reply to: #49569

> Hi
> 
> Is there any reason for we don't support expressions like:
> 
> test() or throw new Exception('test() failed');
> 
> 
> If no, is there any argument against supporting such a syntax in trunk?

Technically, it should be quite easy to have that available, but it
might become tricky to handle cases like: foo(throw exception()); or
even "throw throw throw new Foo;" ? :)

Also, I consider "or die" patterns to be a bad idea, extending it for
exceptions might make it a tad bit better, but I still find that bad
because of i.e. non trivial precedence rules:

include("foo") or throw new Exception("ads");

it will neither include "foo" nor throw any exception.

> 
> -- 
> regards,
> 
> Kalle Sommer Nielsen
> kalle@php.net
> 
> -- 
> 
> 
> 

-- 
Etienne Kneuss
http://www.colder.ch
