develooper Front page | perl.perl5.porters | Postings from May 2010

Re: package block syntax

Thread Previous | Thread Next
Michael G Schwern
May 8, 2010 12:49
Re: package block syntax
Message ID:
On 2010.5.3 7:40 AM, Rafael Garcia-Suarez wrote:
> On 1 May 2010 18:59, Zefram <> wrote:
>> Attached patch is an updated version of my "package Foo { }"
>> implementation.  This fixes the SEGV in parser error recovery and adds
>> more tests.  No one has objected to the new syntax, and a few people
>> have expressed approval, so I think this can be applied.
> Jesse ? I'm not against this patch, but I'm not enthusiastic about it
> either. Do we want this syntactic sugar in ?


For whatever reason I would prefer writing:

    package Foo {


    { package Foo;

when writing small, inline packages and classes.  I don't know if I can put my
finger on exactly what's so odious about the bare block.  Perhaps its the
ordering: declaring the package is the primary concern, scoping it comes
after.  Perhaps its because the package declaration, the critical bit, is at
the wrong scoping level.  Perhaps its because its so different from everything
else in Perl.  Its the only legit use of a bare block left.  We don't write:

    { sub foo;

PS  Don't forget "package NAMESPACE VERSION BLOCK"

191. Our Humvees cannot be assembled into a giant battle-robot.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About