Re: [Templates] Design question

[prev] [thread] [next] [Date index for 2004/06/28]

From: Jeff Anderson
Subject: Re: [Templates] Design question
Date: 21:47 on 28 Jun 2004
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@xxxx.xxx> 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@xxxxxxxxxxxxxxxx.xxx
> http://lists.template-toolkit.org/mailman/listinfo/templates
> 


        -- 
        jeffa

_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates

(message missing)

[Templates] Design question
Buddy Burden 18:58 on 28 Jun 2004

Re: [Templates] Design question
Jeff Anderson 19:16 on 28 Jun 2004

Re: [Templates] Design question
Mark Mills 19:16 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 20:20 on 28 Jun 2004

RE: [Templates] Design question
Bruce McKenzie 20:46 on 28 Jun 2004

Re: [Templates] Design question
Ken.Olstad 20:55 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 21:25 on 28 Jun 2004

Re: [Templates] Design question
Jeff Anderson 21:47 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 16:11 on 01 Jul 2004

Re: [Templates] Design question
Jeff Anderson 18:05 on 01 Jul 2004

Re: [Templates] Design question
Buddy Burden 22:33 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 22:52 on 28 Jun 2004

Re: [Templates] Design question
Buddy Burden 23:18 on 28 Jun 2004

Re: [Templates] Design question
Perrin Harkins 03:21 on 29 Jun 2004

Re: [Templates] Design question
Buddy Burden 16:22 on 29 Jun 2004

Re: [Templates] Design question
Mark Mills 17:09 on 29 Jun 2004

Re: [Templates] Design question
Buddy Burden 17:47 on 29 Jun 2004

[Templates] Design question
Chris Ochs 06:53 on 08 Dec 2004

Generated at 08:55 on 15 Mar 2005 by mariachi v0.52