Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-23 Thread Ferenc Kovacs
2012.07.24. 7:41, "Ivan Enderlin @ Hoa" ezt írta: > > > On 23/07/12 06:03, Alex Aulbach wrote: >> >> In other words: You want to introduce something, which we are glad not >> to need anymore. :) > > Ok. And as I said, it is a proposal so… ;-). > > Next topic: rescue or finally keywoard? > For fin

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-23 Thread Charlie Somerville
rescue is the exact same concept as catch On Jul 24, 2012 3:41 PM, "Ivan Enderlin @ Hoa" < ivan.ender...@hoa-project.net> wrote: > > > On 23/07/12 06:03, Alex Aulbach wrote: >> >> In other words: You want to introduce something, which we are glad not >> to need anymore. :) > > Ok. And as I said, i

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-23 Thread Ivan Enderlin @ Hoa
On 23/07/12 06:03, Alex Aulbach wrote: In other words: You want to introduce something, which we are glad not to need anymore. :) Ok. And as I said, it is a proposal so… ;-). Next topic: rescue or finally keywoard? Best regards :-). -- Ivan Enderlin Developer of Hoa http://hoa.42/ or http://

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-22 Thread Alex Aulbach
2012/7/20 Ivan Enderlin @ Hoa : > On 20/07/12 15:32, Alex Aulbach wrote: >> If you use try/catch that much, that you begin to think about the >> syntax, you have an architecture- or design-problem. > > Not sure about that. First, it was an example. Second, it happens more often > than you think. Fo

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Andrew Faulds
Python isn't coding-style constrained, it just uses increases and decreases whitespace as part of the block syntax. It has considerable flexibility, but not PHP/Perl-level. On Jul 20, 2012 3:33 PM, "Amaury Bouchard" wrote: > 2012/7/20 Alex Aulbach > > > PS: And if without brackets should be forb

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Levi Morrison
On Fri, Jul 20, 2012 at 1:09 PM, Rick WIdmer wrote: > On 7/20/2012 7:51 AM, Léo Peltier wrote: >> >> >> Enforcing coding style should be forbidden. > > > YES!! I just thought that needed to be repeated! > > > > On Fri, Jul 20, 2012 at 3:51 PM, Léo Peltier > wrote: >> >> >> Clearly you don't wo

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Rick WIdmer
On 7/20/2012 7:51 AM, Léo Peltier wrote: > Enforcing coding style should be forbidden. YES!! I just thought that needed to be repeated! On Fri, Jul 20, 2012 at 3:51 PM, Léo Peltier wrote: Clearly you don't work in a team or contribute to Open Source projects. That's what coding styles

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Rafael Dohms
On Fri, Jul 20, 2012 at 3:51 PM, Léo Peltier wrote: > > Enforcing coding style should be forbidden. > Clearly you don't work in a team or contribute to Open Source projects. That's what coding styles are for, keeping code looking the same to make readability easier for not-you developers. --

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Amaury Bouchard
2012/7/20 Alex Aulbach > PS: And if without brackets should be forbidden. > If I wanted a coding style-constrained language, I would use Python.

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Ivan Enderlin @ Hoa
On 20/07/12 15:32, Alex Aulbach wrote: Hi Ivan, try throw new Exception('foobar'); catch(Exception $e) var_dump($e->getMessage()); If you use try/catch that much, that you begin to think about the syntax, you have an architecture- or design-problem. Not sure about that. First, it was an exampl

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Léo Peltier
> If you use try/catch that much, that you begin to think about the > syntax, you have an architecture- or design-problem. "Easier to ask for forgiveness than permission." That's one thing I like about python: exceptions everywhere. Much cleaner than having to use empty/isset/*_exists all the ti

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Alex Aulbach
Hi Ivan, > try > throw new Exception('foobar'); > catch(Exception $e) > var_dump($e->getMessage()); If you use try/catch that much, that you begin to think about the syntax, you have an architecture- or design-problem. PS: And if without brackets should be forbidden. -- Alex Aulbach -- PHP I

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Florian Anderiasch
On 07/20/2012 11:37 AM, Ivan P @ Hoa wrote: > On 20/07/12 11:28, Lester Caine wrote: >> Ivan Enderlin @ Hoa wrote: >>> Finally, I would like to clarify my proposal: I just wanted to >>> discuss about >>> making try/catch braces optional and not criticize PHP syntax… I don't see how making somethin

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Alexey Zakhlestin
On 20.07.2012, at 12:33, Ivan Enderlin @ Hoa wrote: > Making braces optional for try/catch does: > + not break backward compatibility; > + add consistency in the PHP syntax; > ± offer a new way to write buggy programs but no more than with other control > structures (think about goto ;-)). > >

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Ivan Enderlin @ Hoa
On 20/07/12 11:28, Lester Caine wrote: Ivan Enderlin @ Hoa wrote: Finally, I would like to clarify my proposal: I just wanted to discuss about making try/catch braces optional and not criticize PHP syntax… The problem here is rather, could we make brackets compulsory everywhere? No because o

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-20 Thread Lester Caine
Ivan Enderlin @ Hoa wrote: Finally, I would like to clarify my proposal: I just wanted to discuss about making try/catch braces optional and not criticize PHP syntax… The problem here is rather, could we make brackets compulsory everywhere? No because of BC problems, but this might be the pref

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Sara Golemon
For all the reasons already stated, most explicitly because it make the code ugly as sin, my vote is somewhere between "No", and "Hell No." -1 on bracketless try/catch On Thu, Jul 19, 2012 at 2:44 AM, Ivan Enderlin @ Hoa < ivan.ender...@hoa-project.net> wrote: > Hi internals, > > As you certain

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Andrew Faulds
HTML5 allow omitting head, body, html (they had no fundamental differences in parsing IRL), and also quotes and some end tags. Makes for much, much nicer HTML, e.g.: hello hi item 1 item 2 ...that's off-topic though. I don't think we should have more tolerance of omitted braces in PH

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Larry Garfield
There is no such thing as an optional closing tag or brace. There's only lazy and sloppy coders, and parsers that encourage them. --Larry Garfield On 7/19/12 10:52 AM, Andrew Faulds wrote: Always close , but never close :) On Jul 19, 2012 4:44 PM, "Larry Garfield" wrote: On 7/19/12 5:11 A

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Andrew Faulds
Always close , but never close :) On Jul 19, 2012 4:44 PM, "Larry Garfield" wrote: > On 7/19/12 5:11 AM, Peter Beverloo wrote: > > I have seen this problem happen, people losing time trying to figure out >>> what is wrong only to find >>> its a missing bracket. >>> As Paul said, this is bug-pro

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Larry Garfield
On 7/19/12 5:11 AM, Peter Beverloo wrote: I have seen this problem happen, people losing time trying to figure out what is wrong only to find its a missing bracket. As Paul said, this is bug-prone. Other bracket-less blocks allow authors to shoot themselves in the foot equally so, yet PHP sup

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Cyberspice
Probably not so much in PHP but I've had some real doozers in my time due this. For example in C... if (somethingsFailed) DEBUG_MACRO("Something failed!"); var = 1; And then someone un-defines DEBUG_MACRO. Fun then ensues. Melanie On 19 Jul 2012, at 11:03, Charlie Somerville wrote:

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Lester Caine
Sebastian Krebs wrote: Of course it's a matter of code style [1], but one can write the ugliest code with every syntax. This argument about "bug-prone" often confuses me, because I for myself never had such a problem. I also never knew someone, who had a problem with bracket-less blocks (but must

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Sebastian Krebs
2012/7/19 Rafael Dohms > On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville < > char...@charliesomerville.com> wrote: > > > This has code readability problem written all over it. When maintaining > it > > also has problems, like with the bracket-less if's. > > You would need to add brackets if

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread jevon
This reminds me of $var = something or die(); So if you do follow with braceless-try, I would have try something() catch($e) do_something_with($e); Or (a bit simpler, but assumes we have a new pseudovariable $e), try something() or do_something_with($e) I don't like the form with a semi

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Lester Caine
Peter Beverloo wrote: Other bracket-less blocks allow authors to shoot themselves in the foot equally so, yet PHP supports these as well. The actual problem here is an inconsistency in the parser, which I'd consider to be a bug. Having been caught out too many times now when adding an extra par

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Rune Kaagaard
+1 for the consistency of it. It's surprising that: if ($foo) return $bar; else return 42; works and: try maybe_dangerous(); catch(Dynamite $e) handle_error(); does not. On Thu, Jul 19, 2012 at 12:11 PM, Peter Beverloo wrote: > On Thu, Jul 19, 2

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Peter Beverloo
On Thu, Jul 19, 2012 at 11:06 AM, Rafael Dohms wrote: > On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville < > char...@charliesomerville.com> wrote: > > > This has code readability problem written all over it. When maintaining > it > > also has problems, like with the bracket-less if's. > > You

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Rafael Dohms
On Thu, Jul 19, 2012 at 12:03 PM, Charlie Somerville < char...@charliesomerville.com> wrote: > This has code readability problem written all over it. When maintaining it > also has problems, like with the bracket-less if's. > You would need to add brackets if you add an extra line here, as well as

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Rafael Dohms
On Thu, Jul 19, 2012 at 11:58 AM, Charlie Somerville < char...@charliesomerville.com> wrote: > > On Thursday, 19 July 2012 at 7:49 PM, Paul Dragoonis wrote: > > > Why is your try block only going to contain 1 line, and that's > > throwing an exception?? > > > > try > > throw new Exception('foobar'

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Charlie Somerville
> This has code readability problem written all over it. When maintaining it > also has problems, like with the bracket-less if's. > You would need to add brackets if you add an extra line here, as well as > you might get unexpected behaviour of you forget to > add brackets in that case. > >

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Sebastian Krebs
Hi, 2012/7/19 Paul Dragoonis > Why is your try block only going to contain 1 line, and that's > throwing an exception?? > > try > throw new Exception('foobar'); > catch(Exception $e) > > > Braces are a good thing, they give structure and stop people from > mis-reading things and writing bugs, th

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Paul Dragoonis
On Thu, Jul 19, 2012 at 10:58 AM, Charlie Somerville wrote: > On Thursday, 19 July 2012 at 7:49 PM, Paul Dragoonis wrote: > > Why is your try block only going to contain 1 line, and that's > throwing an exception?? > > try > throw new Exception('foobar'); > catch(Exception $e) > > Because it's a c

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Rafael Dohms
On Thu, Jul 19, 2012 at 11:44 AM, Ivan Enderlin @ Hoa < ivan.ender...@hoa-project.net> wrote: > 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

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Charlie Somerville
On Thursday, 19 July 2012 at 7:49 PM, Paul Dragoonis wrote: > Why is your try block only going to contain 1 line, and that's > throwing an exception?? > > try > throw new Exception('foobar'); > catch(Exception $e) > > Because it's a contrived example. He's not trying to write real code, he

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Alexey Zakhlestin
On 19.07.2012, at 13:49, Paul Dragoonis wrote: > 2) Try with only one line in it to throw an exception doesn't seem > like a realistic situation. It could be something like this: try $object->method(); catch (\Exception $e) return false; and ->method(), obviously, can have quite a long and co

Re: [PHP-DEV] Make try/catch brackets optinal

2012-07-19 Thread Paul Dragoonis
Why is your try block only going to contain 1 line, and that's throwing an exception?? try throw new Exception('foobar'); catch(Exception $e) Braces are a good thing, they give structure and stop people from mis-reading things and writing bugs, the same can be said for the if() situation. 1) Br