Make try/catch brackets optinal

From: Date: Thu, 19 Jul 2012 09:44:39 +0000
Subject: Make try/catch brackets optinal
Groups: php.internals 
Request: Send a blank email to internals+get-61463@lists.php.net to get a copy of this message
Hi internals, As you certainly know, brackets defining blocks in PHP are optional if blocks contain a single instruction. Thus: if($condition) { echo 'foobar'; } is strictly equivalent to: if($condition) echo 'foobar'; But this syntactic sugar is not applied uniformly to all PHP language constructions. I have the try/catch couple in mind. First, I would like to know why it is not possible to write: try throw new Exception('foobar'); catch(Exception $e) var_dump($e->getMessage()); as a strict equivalence of: try { throw new Exception('foobar'); } catch(Exception $e) { var_dump($e->getMessage()); } Second, if it is possible, could we plan to have this “feature” (uniformity actually) in PHP6 (or maybe before)? Best regards. -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/

« previous php.internals (#61463) next »