Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

What namespace??

by Sinister (Friar)
on Oct 08, 2002 at 07:51 UTC ( #203584=perlquestion: print w/replies, xml ) Need Help??

Sinister has asked for the wisdom of the Perl Monks concerning the following question:

Fellow monks,

Let me begin by saying this might just as well have been posted in meditations, for I have meditated on it for a little while now, but I need your wisdom on it, so I posted it right here.

I received word yesterday that my request for a CPAN-ID has been approved *cheer* -- I obviously requested this ID because I have something I want to put up there.

I am working on a module that does all the things modules like Class::Struct, Class::MethodMaker and Class::Accessor do but with a nicer syntax and some xtra other features. The work-name for this thing is AccessorMaker, so I was thinking about requesting Class::AccessorMaker as my namespace, but was wondering wheter or not you monks find this to confusing or clashing with other modules out there...

Thanks in advance for your wise answerings

er formait hyarya.
-- "Life is a house and the next tornado is never far away"
-- "lovely by nature"

Replies are listed 'Best First'.
Re: What namespace??
by theorbtwo (Prior) on Oct 08, 2002 at 08:13 UTC

    Class::AccessorMaker seems like a reasonable name, though given your description, Class::AllDancing or Class::BellsAndWhistles seems perhaps more approprate (that's humor, not criticisim, BTW)... I'm also fond of Class::AutoAccessor, but just because I coined it (the term, that is) (or at least came up with it independently) for a perl6 RFC.

    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: What namespace??
by diotalevi (Canon) on Oct 08, 2002 at 13:23 UTC

    Have you considered posting the code in Code Catacombs or on your scratchpad? It'd be nice to see what you're doing even if you're not asking for naming help.

    __SIG__ printf "You are here %08x\n", unpack "L!", unpack "P4", pack "L!", B:: +svref_2object(sub{})->OUTSIDE
      I did consider to do that, but, as development is not fully done, I decided not to.

      Nevertheless I will supply you with the POD - which should be more of a reference to a propper name, then the code itself (right?)

      Class::AccessorMaker generate common accessor method with default values.
      With constructor package Users; use Class::AccessorMaker { username => "guest", password => "", role => "guest", groups => [ "guest" ] }; package main; my $usr = Users->new(username => $uname, password => $pw); With init constructor package MailThing; use Class::AccessorMaker { to => "", from => "hartog\", cc => "", bcc => "", bounce => "" }, "new_init"; sub init { my ($self) = @_; ... } package main; my $mlr = MailThing->new(); Without constructor package HitMan; use Class::AccessorMaker { victim => "", location => "", data => {} }, "no_new"; sub new { my $class = ref($_[0]) or $_[0]; shift; return bless({}, $class); } package main; Of course the first example describes some sort of user system, which assumes you are a guest by default. The second example is some sort of mailer-object. And the third is used by a lot of serial killers out there...
      The AccesorMaker takes in, at use-time, a hash-reference and an extra keyword. It uses the keys of the hash-reference to create accessor-methods in the namespace of the caller. The values that are given to the keys are the default value of the accessor. Class::AccessorMaker will create a constructor (called "new()") by default. This constructor will be able to take that nice and shiny hash-like structure as you can see in the first example. If you want your constructor to run your objects "init()" routine you can specify the keyword "new_init". If you want to write your own "new()" routine you can use "no_new".
      This module is still under some sort of development, and I am expecting to release things like ReadOnly / WriteOnce accessor methods in the near future. I alredy have Class::AccessorMaker::Private out there for you, which could prove to be very usefull for you.
      Please do not put those perl-reserved names in there like DESTROY, import, AUTOLOAD, and so on. It will hurt you badly. Q: "But why do you not filter those?" A: "This is perl baby, you can do whatever you like..." And besides, there is going to be someone out there who is actualy going to put it to good use...
      Hartog 'Sinister' de Mik <>

      Any good for you?

      er formait hyarya.
      -- "Life is a house and the next tornado is never far away"
      -- "lovely by nature"

Redo: What namespace??
by Sinister (Friar) on Oct 08, 2002 at 09:12 UTC

    I was suddenly struc by some beam of light, and it occured to me that my module is more of an Object::Template - but that would be a very ambigious name... Nevertheless it would be more appropriate...

    *Sinister sighs and mumbles: "Wrong choises, wrong choises"

    edit: Just realized that this doesn't make any sence ... sowwy

    er formait hyarya.
    -- "Life is a house and the next tornado is never far away"
    -- "lovely by nature"

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://203584]
Approved by fireartist
Front-paged by fireartist
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2022-08-15 06:35 GMT
Find Nodes?
    Voting Booth?

    No recent polls found