develooper Front page | perl.documentation | Postings from July 2011

Re: new package syntax, where do I return true?

Thread Previous | Thread Next
From:
Chas. Owens
Date:
July 2, 2011 05:54
Subject:
Re: new package syntax, where do I return true?
Message ID:
CAH2YjjFvt6kU7-udRt+ZBmEKViG1SBrAw4Jr+Z-CWwHHHzq6WQ@mail.gmail.com
On Sat, Jul 2, 2011 at 00:00, Caleb Cushing <xenoterracide@gmail.com> wrote:
> Having a little debate over this on a Perl::Critic ticket. I'm not
> sure anyone is sure and the docs don't say.
>
> https://rt.cpan.org/Ticket/Display.html?id=69234
>
>
> is it package foo { ... 1; }  or package foo { ... }; 1; ? or what?
> and is it possible this could get clarified in the next edition of the
> docs?
> --
> Caleb Cushing
>
> http://xenoterracide.com
>

My take on this is that

package Foo {
}

is the same thing as

{
package Foo;
}

Therefore, if your style allowed

{
package Foo;
1;
}

then it should allow

package Foo {
    1;
}

However, I think you can make a good argument for not allowing that.
A module is not a package.  The fact that it is customary for modules
to consist of one package sometimes confuses this, but there is no
requirement that a module include a package at all.  From that basis,
I would argue that

package Foo {
}

1;

is more correct.

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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