Skip Menu |

This queue is for tickets about the MooseX-Types CPAN distribution.

Report information
The Basics
Id: 51511
Status: rejected
Priority: 0/
Queue: MooseX-Types

People
Owner: Nobody in particular
Requestors: mnology [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.20
Fixed in: (no value)



Firs,t I'll admit this may be a 'me' issue, but I'm finding it really hard to understand why its the case. Attempting to -declare types like so: my @types = qw(AType More Types); use MooseX::Types -declare => \@types; subtype Atype, ... subtype More, ... ... Results in: Bareword "Atype" not allowed while "strict subs" in use ... Bareword "More" not allowed while "strict subs" in use ... Though declaring via use MooseX::Types -declare => [qw(AType More)]; Executes the subtype declarations just fine, without bareword complaints. I'm trying to eliminate some clutter and reuse the list in another enum declaration and thats why I want to define a list. OpenBSD minotaur.mnology.com 4.6 GENERIC.MP#0 amd64 This is perl, v5.10.1 (*) built for amd64-openbsd
On Fri Nov 13 14:57:33 2009, http://openid.mnology.com/mnology wrote: Show quoted text
> Firs,t I'll admit this may be a 'me' issue, but I'm finding it really > hard to understand why its the case. > > Attempting to -declare types like so: > > my @types = qw(AType More Types); > use MooseX::Types -declare => \@types;
Just for kicks, what does: my $types = [qw(AType More Types)]; use MooseX::Types -declare => $types; give you? Show quoted text
> > subtype Atype, ... > subtype More, ... > ... > > Results in: > Bareword "Atype" not allowed while "strict subs" in use ... > Bareword "More" not allowed while "strict subs" in use ... > > Though declaring via > use MooseX::Types -declare => [qw(AType More)]; > > Executes the subtype declarations just fine, without bareword > complaints. > > I'm trying to eliminate some clutter and reuse the list in another > enum declaration and thats why I want to define a list. > > OpenBSD minotaur.mnology.com 4.6 GENERIC.MP#0 amd64 > This is perl, v5.10.1 (*) built for amd64-openbsd >
Show quoted text
> Just for kicks, what does: > > my $types = [qw(AType More Types)]; > use MooseX::Types -declare => $types; > > give you?
I've tried this as well with identical results. I ended up assigning initializing @types and assigning it in a BEGIN block. Which allowed me to reuse it. But it's not really the cleanest solution, which is where I feel the power of Moose & children lies. I feel I should also point out here that my real world code includes a type called 'Class'. Befure using the BEGIN Block the Class subtype definition would not recieve the Bareword complaint. Codepaste during my irc.perl.org #moose foray: http://scsys.co.uk:8001/36178
This is not a bug. It's how perl's compile- and runtime works. You probably meant my @types; BEGIN { @types = qw(Foo Bar) } use MooseX::Types -declare => \@types;
Yeah, I figured this out eventually. The documentation under "LIBRARY DEFINITION" suggests the following usage: 'The only thing a library is required to do is use MooseX::Types -declare => \@types;' Which I guess is enough information under certain assumptions.
Replying to closed bugs re-opens them. Please don't do that unless you really want to, for example if you think the documentation on this is unclear and you have a suggestion on how we could make it better.