Mailing List Archive

[perl #17571] slight package name irregularity
On Sat Apr 28 22:48:05 2012, Hugmeir wrote:
> This is still present in blead. I think it should either be rejected, or
> marked as WontFix; Any sort of fix now would be backwards-incompatible,
> and I can't see the gain.

It does feel like a bug to me though, that ‘package foo::’ does not
remove ::, while foo:: anywhere else does lose its colons.

A quick CPAN grep for package.*::\s*; brings up nothing.

>
> What would be nice (maybe worth filing a second ticket?) is getting a
> note in the docs that barewords with trailing ::'s get trimmed:
>
> perl -MDevel::Peek -wE '$x = \etc::; Dump $x'

I thought that was documented. Or maybe that was in the Camel.

--

Father Chrysostomos


---
via perlbug: queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=17571
[perl #17571] slight package name irregularity [ In reply to ]
On Wed Sep 25 11:56:49 2002, pcg@goof.com wrote:
> On Wed, Sep 25, 2002 at 12:11:18PM -0000, Rafael Garcia-Suarez
> <perlbug@perl.org> wrote:
> > The question is : should perl remove trailing colons from the 2nd
> > string argument to bless ? I think it should. Currently the
> following :
>
> Is it? I didn't expect such a simple almost-non-problem to spark not
> only so
> much response but also so much different opinions ;)
>
> Ok, I think we agree on that the current situation isn't right.
>
> > sub foo { print "hello\n" }
> > $x = bless {}, 'main::';
>
> :: is just a way to quite (at least I read this out of the docs), so
> hello:: is just the string "hello".
>
> On the perl level, "::" in package names are not much of a divisor, I
> could name my packages equally well like IO_Socket_INET etc., and
> apart
> from some minor differences this would be consistent (perl doesn't
> allow
> relative "namespaces" or package/namespace imports/aliase, like e.g.
> modula-2 or java does)
>
> So I'd like to argue that "::" is an almost normal psrt of a package
> name.
> The only exception is that "barewords" (or mor specifically package
> names)
> with "::" at the end get properly quoted.
>
> So my only problem is that
>
> package packagename;
>
> *looks* like expecting a bare package name (an expression isn't
> allowed,
> afaics), but actually uses it's own set of parsing rules, leaving
> trailing
> "::" intact.
>
> So, my line of thought is: ok, "package" doesn't follow normal lexing
> rules for strings, it expects a package name. package names can be
> quoted
> using trailing "::". So package should accept this and strip the "::".
>
> However, when one uses strings (bless {}, "foo::") no such quoting
> occurs.
> Different level, namely, bless expects a package name as a string,
> always. No
> special :: removal.
>

This is still present in blead. I think it should either be rejected, or
marked as WontFix; Any sort of fix now would be backwards-incompatible,
and I can't see the gain.

What would be nice (maybe worth filing a second ticket?) is getting a
note in the docs that barewords with trailing ::'s get trimmed:

perl -MDevel::Peek -wE '$x = \etc::; Dump $x'


---
via perlbug: queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=17571