Module naming help

Module naming help

am 27.04.2006 16:29:41 von Timothy Hinchcliffe

I have written 2 modules which I intend to upload to CPAN.
I have chosen the names "Class::MethodVars" and "Class::Framework", they
would both be uploaded in Class-Framework-??.??.tar.gz unless anyone has
better suggestions.

The first currently called Class::MethodVars allows you to tag a sub with
":Method" and get access to "this" (in various configurable forms).

Eg:
package MyClass;
use warnings;
use strict;

use Class::MethodVars qw( -fieldvars ),-field=>"internal_variable";

sub new :ClassMethod {
return bless({},__CLASS__); # Class is provided my the magic
of :ClassMethod
}

sub mymethod :Method {
my ($arg) = @_; # Note that object has been removed from @_
this->{internal_variable}++;
this->othermethod($arg);
${^_internal_variable}++; # This is an alias to this->{internal_variable}
}

"this" can be renamed and/or configured to be a variable (which is
automatically added to "use vars" to remain strict-safe).

The second module is currently called Class::Framework. It combines
Class::MethodVars with fields (as in "use fields") and Class::Accessor to
build an class for you.

Eg:
package MyClass;
use warnings;
use strict;

use Class::Framework
-fields=>qw( a b cde ), # creates with ->mk_accessors(qw( a b cde ));
-rofield=>"rofield", # creates with ->mk_ro_accessors(qw( rofield ));
-hiddenfield=>"hidden"; # No accessor created.

# new() is inherited for you.

sub concat_fields :Method {
return join("",this->a,this->b,this->cde,this->rofield,this->{hidde n});
}

package main;

my $mc = MyClass->new(a=>1,b=>2,cde=>3,rofield=>4,hidden=>5);
print $mc->concat_fields; # Prints "12345"

__END__

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----