I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2005-02-02 19:13:01-08 by theory
This is not your CPAN's Meta

No, it's not part of the Meta namespace on CPAN. Class::Meta does class automation, data type validation, and provides an introdpection interface (metadata) for your classes.

So, what are you using Class::Meta for?

Cheers,

David

Direct Responses: 165 | Write a response
Posted on 2005-02-28 22:10:28-08 by tkc in response to 13
Re: This is not your CPAN's Meta

I use Class::Meta. I'm considering making it a way of life... Thanks!

I've extended it a bit with a Constructor that calls _initialize when it's done. I've also created a MethodCheckParameter class which creates the actual method (like a constructor with create=>1). That method validates the paramters passed in and creates and instance of a special dynamically built class::meta to hold those parametets. It uses goto to make the final call which is nice because "caller" still works as expected.

Unfortunately, I had to fork Meta.pm as opposed to extend it because the add_method sub did not add the method to $classes->{<package>}->{build_meth_ord}. I filed a CR with bugs-class-meta@cpan.org (#11689) about this.

It works like this:
#!/usr/bin/perl -w use strict; package myclass; use TKC::Meta; use TKC::Meta::ConstructorInitialize; use TKC::Meta::MethodCheckParameters; use Class::Meta::Types::String qw(semi-affordance); BEGIN { my $cm = TKC::Meta-&gt;new(constructor_class =&gt; "TKC::Meta::ConstructorInitialize", method_class =&gt; "TKC::Meta::MethodCheckParameters", ); $cm-&gt;add_constructor(name=&gt;"new", create=&gt;1); my $meth = $cm-&gt;add_method(name=&gt;"mymeth"); $meth-&gt;add_parameter(name=&gt;'parameter', type=&gt;'string'); $cm-&gt;build(); } sub _initialize { my ($this) = @_; print "INITIALIZE for: ",$this,"\n"; } sub _mymeth { my ($this, $params) = @_; print "THIS : ",$this, "\n"; print "PARAMS : ",$params, "\n"; print "CALLER : ",join(", ",caller), "\n"; print "PARAMETER: ",$params-&gt;parameter, "\n"; } 1;
When called by a little program in mytest.pl:
#!/usr/bin/perl -w use strict; use myclass; my $c = myclass-&gt;new(); $c-&gt;mymeth(parameter=&gt; "this is a string"); exit(0);
You get the following output:
# perl mytest.pl INITIALIZE for: myclass=HASH(0x80f606c) THIS : myclass=HASH(0x80f606c) PARAMS : myclass::mymeth_parameters=HASH(0x81008a4) CALLER : main, mytest.pl, 6 PARAMETER: this is a string
Direct Responses: 192 | Write a response
Posted on 2005-03-09 02:07:15-08 by theory in response to 165
Re: This is not your CPAN's Meta
Cool. Thanks for your patch. I've applied it and will release a new version soon.
Direct Responses: Write a response