develooper Front page | perl.module-authors | Postings from June 2008

Must exist, right?

Thread Next
From:
Andy Armstrong
Date:
June 18, 2008 16:35
Subject:
Must exist, right?
Message ID:
7D530063-3548-428A-ABD1-D101E9500965@hexten.net
I assume there's a module that works like this?

     package MyFoo;

     use Data::Auto::Objectify::Thing qw( my_data_field );

     sub new {
         bless {
             my_data_field => {
                 foo => [ 1, 2, 3 ],
                 bar => { eat => 'drink', sleep => 'wake' },
             }
           },
           shift;
     }

     package main;

     my $my_foo = MyFoo->new;

     my $two = $my_foo->foo( 1 );
     my $eat = $my_foo->bar->eat;

In other words I want it to synthesise accessors based on the contents  
of a complex data structure. For bonus points it might also allow

     # Can use subscript notation for hashes
     my $eat = $my_foo->bar('eat');

And maybe allow multiple subscripts so that, for example, if I had a  
field called 'grid' that contained a rectangular array I could then do

     my $point = $my_bar->grid(3, 5);

It's got to exist, right? I had a look but there are so many  
^(?:Object|Data)::.* modules that it's a bit hard to see the wood for  
the trees :)

--
Andy Armstrong, Hexten


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About