Re: [Templates] Design question
[prev]
[thread]
[next]
[Date index for 2004/06/28]
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)
|