Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Package-Stash CPAN distribution.

Report information
The Basics
Id: 72057
Status: open
Priority: 0/
Queue: Package-Stash

People
Owner: Nobody in particular
Requestors: DAMI [...] cpan.org
ether [...] cpan.org
Cc: ribasushi [...] cpan.org
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: over-strict rules for module names
Download (untitled) / with headers
text/plain 802b
This is not really a bug, but rather a request for change of design. The new() method only accepts package names with letters, digits and underscores (otherwise it complains "package is not a module name"). I guess that this restriction was inspired by Perl's "package" directive. However, one of the reasons for playing with symbol tables through Package::Stash or other similar modules might be precisely to get more freedom than using compile-time "package" : for example when designing private implementation classes on the fly, it can be useful to use special characters in the class name. Perl has no problem handling stashes containing @#°§:! ; if you play directly with globs and %..:: arrays, you can do it easily. So I suggest to drop that regex constraint in the new() method.
+1 Doy - what is the holdup on this one?
Download (untitled) / with headers
text/plain 282b
On 2012-12-10 02:43:31, RIBASUSHI wrote: Show quoted text
> +1 > > Doy - what is the holdup on this one?
I'd be happy to take over curation of this module if tuits are in short supply. I could have a go at the patch as well, although I'll need another set of eyes to tell me when I'm being dumb :)
Subject: Re: [rt.cpan.org #72057] over-strict rules for module names
Date: Mon, 04 May 2015 15:02:40 -0400
To: bug-Package-Stash [...] rt.cpan.org
From: Jesse Luehrs <doy [...] tozt.net>
Download (untitled) / with headers
text/plain 519b
I'll look at this next week. -doy On May 4, 2015 2:25:59 PM EDT, Karen Etheridge via RT <bug-Package-Stash@rt.cpan.org> wrote: Show quoted text
> Queue: Package-Stash > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72057 > > >On 2012-12-10 02:43:31, RIBASUSHI wrote:
>> +1 >> >> Doy - what is the holdup on this one?
> >I'd be happy to take over curation of this module if tuits are in short >supply. I could have a go at the patch as well, although I'll need >another set of eyes to tell me when I'm being dumb :)
CC: ;
Subject: Re: [rt.cpan.org #72057] over-strict rules for module names
Date: Tue, 12 May 2015 22:39:17 -0400
To: Jesse Luehrs via RT <bug-Package-Stash [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
Download (untitled) / with headers
text/plain 999b
So, one concern I have is, if we are going to allow everything, what about stash entries that contain `::`? Right now, Package::Stash->new("Foo::Bar") creates %::{Foo}{Bar}, but how would you create %::{'Foo::Bar'}? It seems weird to allow everything else except for that. On Mon, May 04, 2015 at 03:02:53PM -0400, Jesse Luehrs via RT wrote: Show quoted text
> Queue: Package-Stash > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72057 > > > I'll look at this next week. > > -doy > > On May 4, 2015 2:25:59 PM EDT, Karen Etheridge via RT <bug-Package-Stash@rt.cpan.org> wrote:
> > Queue: Package-Stash > > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=72057 > > > > >On 2012-12-10 02:43:31, RIBASUSHI wrote:
> >> +1 > >> > >> Doy - what is the holdup on this one?
> > > >I'd be happy to take over curation of this module if tuits are in short > >supply. I could have a go at the patch as well, although I'll need > >another set of eyes to tell me when I'm being dumb :)
> >
Subject: Re: [rt.cpan.org #72057] over-strict rules for module names
Date: Sat, 16 May 2015 10:27:04 +0200
To: bug-Package-Stash [...] rt.cpan.org, DAMI [...] cpan.org, ether [...] cpan.org
From: Laurent Dami <laurent.dami [...] free.fr>
Download (untitled) / with headers
text/plain 889b
My original request was to be able to create namespaces such as Package::Stash->new("Foo<=>Bar"). I use such "strange names" for automatic classes generated by DBIx::DataModel, but there are other modules with similar techniques (like for example the strange namespaces used by overload.pm). The special case "Foo::Bar" should remain as it is, for obvious reasons of backwards compatibility and playing nicely with other perl namespace features. Thanks in advance, Laurent Dami Le 13.05.2015 04:40, Jesse Luehrs via RT a écrit : Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=72057 > > > So, one concern I have is, if we are going to allow everything, what > about stash entries that contain `::`? Right now, > Package::Stash->new("Foo::Bar") creates %::{Foo}{Bar}, but how would you > create %::{'Foo::Bar'}? It seems weird to allow everything else except > for that. > >
Download (untitled) / with headers
text/plain 2.4k
On Tue May 12 22:40:00 2015, doy@tozt.net wrote: Show quoted text
> So, one concern I have is, if we are going to allow everything, what about > stash entries that contain `::`? Right now, Package::Stash->new("Foo::Bar") > creates %::{Foo}{Bar}, but how would you create %::{'Foo::Bar'}? It seems > weird to allow everything else except for that.
Perl does not allow you to refer to such entries by any “normal” means (i.e. symbolic references etc). The only way to get back to them is by lookup in the stash hash and properly dereferencing the resulting glob value. That’s pretty useless. So for most users this will be a trap and/or a nuisance to work around, not a useful feature. In fact I’m pretty sure that *most* of them will expect to get `%::{Foo}{Bar}` when they give you `Foo::Bar`. If you want to ensure the interface is completely regular in case that should ever be needed, maybe allow passing an arrayref instead of a string, and when the caller does that, use the elements as nested stash names, verbatim. Then the answer to your question would be `Package::Stash->new(["Foo::Bar"]`). (And `Package::Stash->new("Foo::Bar")` or `Package::Stash->new(["Foo","Bar"])` would be the ways to produce `%::{Foo}{Bar}`.) But giving someone `%::{'Foo::Bar'}` when they didn’t ask for that in a very explicit way would be a very shitty default. It is certain to be surprising and inconvenient to almost every user of the module. Not surprising in the sense of “I didn’t know it was going to do that” (obviously the behaviour ought to be documented clearly) but in the sense of “after using Package::Stash for a while in simple cases and never having to think about that issue, I totally forgot I had to watch out for that”. Also, of course: backcompat. (Which is probably the first thing I should have brought up.) There is already code that uses Package::Stash, which very much shouldn’t suddenly change meaning. Making people request fully verbatim package names by way of an arrayref would make it unambiguous what semantics they expect when passing a string, which would otherwise differ between existing code and newly written code. Turns out, though, once you’ve come that far, you can just punt on the matter. YAGNI etc, since if someone does ever need it, you can then implement the pass-arrayref-for-fully-verbatim semantics without any break in backcompat. So there is no need to implement that until the day it’s needed. And that day may never come. Does that alleviate your concern?


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.