Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: declaration order of attributes in Moose

by kyle (Abbot)
on Apr 13, 2009 at 21:10 UTC ( #757279=note: print w/replies, xml ) Need Help??


in reply to declaration order of attributes in Moose

Your hacky way of getting what you want doesn't work with the Moose I'm using (0.51). Here I can get a list of slots this way:

my @atts = $h->meta->get_meta_instance->get_all_slots;

That gives the list in no particular order, however.

Looking at the object with Data::Dumper, I don't see any place that stores an ordered list of attributes. I suspect that your "working" code is working by coincidence. Try it with this package:

package Hubba; use Moose; foreach my $name ( 'a' .. 'z' ) { has $name => ( is => 'rw' ); }

I think the only way you're going to get what you want is to look into Moose's definition of has and patch it so that it tracks the information you want to have.

You've asked us not to question your motives here, so I won't, but any code that requires this information probably has a design problem of some kind. I recommend finding another solution to whatever your real problem is.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://757279]
help
Chatterbox?
[ambrus]: Discipulus: sure, it's just that, look, some people (including me) have such unreadable and slow handwriting that writing an article or slides by hand would be a very bad idea.
[choroba]: it might bery useful for other verbs, too
[ambrus]: (and I have a need for at least decent formatting too)
[Discipulus]: when I was used to hand writing I reached a very good level, but chars were ~1mm

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2017-09-26 11:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?