logo       

Re: Design question: msg#00103

Subject: Re: Design question
Buddy, with all due respect, it seems to me that your "wheel" is not
exactly round, at least not as round as picking another solution.

Personally, i avoid objects that treat hashes and arrays the same ...
sure it might make your code "cooler" ... but's it not exactly
rational. After all, why is there a distinction between hashes and
arrays in the first place? And didn't we discover that pseudohashes
were not a great idea after all?

Either you need a hash or you need an array ... why not serve up the
proper datastructure instead of trying to guess what it is in your
code? Because you can use one for all cases? That's hardly a gain in
my books ... because it is a trade off. I think you are feeling the
pain of that trade off now. :/

Best of luck to you, i hope you do figure this out without having to
change much code.

On Mon, 28 Jun 2004 17:25:36 -0400, Perrin Harkins 
<perrin-rcKlk6LmnZA@xxxxxxxxxxxxxxxx> wrote:
> 
> On Mon, 2004-06-28 at 14:58, Buddy Burden wrote:
> > Now I have a design question.  I have an object, which acts (FTMP) like
> > a Perl pseudohash.  Specifically, you can use it like a hashref, or like
> > an arrayref.  I use it for storing rows I get back from the database.
> > Consequently, I have lots of arrays of these lying around, which I
> > naturally want to get into templates.
> >
> > My first attempt was just to toss an array into the $vars I send to TT2.
> >   This didn't work, of course, because even though you can _use_ it like
> > a hashref, it _isn't_ a hashref.  It's an object.
> 
> Actually, a tied hash is not an object.  Maybe you're passing something
> else?
> 
> I'm not sure about the XS Stash, but the Perl Stash should do the right
> thing on tied hashes and arrays, because they return "HASH" or "ARRAY"
> in response to ref(), unlike objects.  For demonstration:
> 
> use Tie::Hash;
> 
> my %hash;
> my $obj = tie %hash, 'Tie::StdHash';
> 
> my $hash = \%hash;
> print "ref: " . (ref $hash) . "\n";
> print "ref: " . (ref $obj)  . "\n";
> 
> - Perrin
> 
> 
> 
> 
> _______________________________________________
> templates mailing list
> templates-MnLy+PD7ppGDO3lXZvfOKmD2FQJk+8+b@xxxxxxxxxxxxxxxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
> 


-- 
jeffa


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe