New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slight package name irregularity #5956
Comments
From pcg@goof.comCreated by root@cerebro.laendleThe package statement accepts package names with trailing "::" without removing them, so package test::; die __PACKAGE__; outputs "test::", which imho is not expected (writing "bless $ref, test::" In my opinion either the package statement should rmeove the extra "::"'s, Perl Info
|
From @rgsMarc Lehmann (via RT) <perlbug@perl.org> wrote:
I prefer the first suggestion. Consider also : $ perl -le 'print bless{},"foo::"' I think that both should return the same result. |
From schuller@lunatech.comOn Wed, Sep 25, 2002 at 12:59:38PM +0200, Rafael Garcia-Suarez wrote:
It's always been possible to bless into an arbitrary string: $ perl -le 'print bless{},"<>:&%$#@"' Although I personally would have no problems if it were changed to check -- |
From @rgsBart Schuller <schuller@lunatech.com> wrote:
It's kind of a valid package name : #!perl The question is : should perl remove trailing colons from the 2nd sub foo { print "hello\n" } fails with |
From pcg@goof.comOn Wed, Sep 25, 2002 at 11:57:46AM -0000, Bart Schuller <perlbug@perl.org> wrote:
I know, still I think there shouldn't be different parsing rules for
I wasn't talking about blessing or valid package names, but about unquoted package xyz::; bless {}, xyz::; bless into different packages. while: package "<>:&%$#@"; are simply syntax errors. This is more like: "x-x" is a valid string, but x-x is not.
"<>:&%$#@" should IMHO be a valid package name - just not unquoted. -- |
From mjtg@cam.ac.ukMarc Lehmann wrote
It's entirely to be expected. Null fields are entirely legitimate
That's rather misleading. Watch: DB<1> x bless [], 'test:' It's not the bless() that's removing the '::' (and it would be totally DB<1> x test:: [ Incidentally, there seems to be something odd in the debugger here. DB<2> x use strict;temp:: Bart Schuller <schuller@lunatech.com> wrote
That would break all sorts of things. For better or worse, variable And bless *does* check if you give it a classname argument rather than a perl -we 'use strict; print bless [], test::' Mike Guy |
From pcg@goof.comOn Wed, Sep 25, 2002 at 12:11:18PM -0000, Rafael Garcia-Suarez <perlbug@perl.org> wrote:
Is it? I didn't expect such a simple almost-non-problem to spark not only so Ok, I think we agree on that the current situation isn't right.
:: is just a way to quite (at least I read this out of the docs), so On the perl level, "::" in package names are not much of a divisor, I So I'd like to argue that "::" is an almost normal psrt of a package name. So my only problem is that package packagename; *looks* like expecting a bare package name (an expression isn't allowed, So, my line of thought is: ok, "package" doesn't follow normal lexing However, when one uses strings (bless {}, "foo::") no such quoting occurs. -- |
From @HugmeirOn Wed Sep 25 11:56:49 2002, pcg@goof.com wrote:
This is still present in blead. I think it should either be rejected, or What would be nice (maybe worth filing a second ticket?) is getting a perl -MDevel::Peek -wE '$x = \etc::; Dump $x' |
From @cpansproutOn Sat Apr 28 22:48:05 2012, Hugmeir wrote:
It does feel like a bug to me though, that ‘package foo::’ does not A quick CPAN grep for package.*::\s*; brings up nothing.
I thought that was documented. Or maybe that was in the Camel. -- Father Chrysostomos |
From schmorp@schmorp.deOn Sun, Apr 29, 2012 at 12:27:01AM -0700, Father Chrysostomos via RT <perlbug-followup@perl.org> wrote:
"package" is purely syntax, not a function that expects a string. i would package "my::" . $pkgname; But use cases for that are probably nonexistant (because it would be As it stands, word:: is just quoting syntax (and yes, surprisingly, In fact, it would have potential to confuse newcomers, as the :: really -- |
Migrated from rt.perl.org#17571 (status was 'open')
Searchable as RT17571$
The text was updated successfully, but these errors were encountered: