[Chicago-talk] Class::Accessor uses a hashref - a question of style

Jim Thomason jthomasoniii at yahoo.com
Sun Jan 25 13:57:03 CST 2004


> Now the question:  Is it just a personal preference
> to use a hash or a
> hashref when creating a class.  Or is one one syntax
> preferred by those
> people who make the rules?

As far as I'm concerned, it's a personal preference.

Some people prefer it, since you're passing by
reference instead of by value. Realistically? As long
as those hashes or keys or values or whatever aren't
huge, it's not going to make a difference 99 times out
of 100. Speed and memory won't be perceptibly
affected.

I've also heard it used in times where someone wants
to keep open the option of passing in additional
arguments outside of that hash value.
($class->new(\%args, $someothervar)). Again, I'd
personally rather stick 'em in that args hash.

The only other possible advantage I can conceive of is
that you're not required to de-reference a hashref if
you already have one.

I'd say that consistency is usually more important
than one or the other. Pick one and stick with it, if
possible.

-Jim....

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/



More information about the Chicago-talk mailing list