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

Re: package block syntax

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
May 8, 2010 12:49
Subject:
Re: package block syntax
Message ID:
4BE5C030.4010209@pobox.com
On 2010.5.3 7:40 AM, Rafael Garcia-Suarez wrote:
> On 1 May 2010 18:59, Zefram <zefram@fysh.org> 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 ?

+1

For whatever reason I would prefer writing:

    package Foo {
        ...
    }

over

    { 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
           http://skippyslist.com/list/

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About