News for hackers. Stuff that matters.
Re:PHP doesn't need 'finally' by bad_user on Friday December 10, 2010 @07:18AM (#1991412)
That's a neat example, but you're abusing Perl's syntax for that syntactic-sugar, and it doesn't work like that in PHP (e.g. parens cannot be omitted, and does this code even compile with "use strict"?)
Re:PHP doesn't need 'finally' by jrockway on Friday December 10, 2010 @07:54AM (#1991487)
It compiles with "use strict", and it's not abuse.

The reason you can't compile it is because guard is not defined, nor are cwd, cleanup, and the other placeholder functions I used. When you are relying on the parser to add parens for you (and let you omit "sub"), you have to have the function in scope. Compare:

    use strict;
    sub foo { bar }
And

    use strict;
    sub bar;
    sub foo { bar };
Re:PHP doesn't need 'finally' by bad_user on Friday December 10, 2010 @02:45PM (#1992872)
"abuse" was not the word I was looking for: I meant you're using Perl's syntactic freedom, and this trick does not work with PHP.
Re:PHP doesn't need 'finally' by jerf on Friday December 10, 2010 @11:16AM (#1992073)
If you think that's "abusing" Perl 5 syntax for a useful effect, you should start reading up on Perl 6. Though you probably shouldn't if you have a weak heart.
Re:PHP doesn't need 'finally' by chromatic on Friday December 10, 2010 @11:59AM (#1992242)
[You're] abusing Perl's syntax for that syntactic-sugar...

Those are designed, documented, and tested features; they exist to do exactly this.