[Petal] Re: Using Test::More

Jean-Michel Hiver jhiver at mkdoc.com
Thu Apr 10 01:52:36 BST 2003


> Yes, sorry I wan't too clear about that. try the following benchmark
> <snip>

Right! Interesting. Well, I would have amended the CodeGenerator but 
since you're doing it on what could be a drop-in replacement for the 
CodeGenerator I might just do nothing :)


> The main difference is that I don't use the Petal hash, I just use an 
> ordinary hash. I parse all the expressions beforehand so compile time
 > is longer but then execution is speeded up a lot.

I see... So basically rather than having Petal::Hash::VAR evaluating 
your expression you get the CodeGenerator to do it. Hum... interesting! 
Maybe each modifier could have a as_perl() method that returns a do { 
... } block, so that nesting them would be trivial?

Indeed if the code which is produced stayed indented that'd be ideal!


> do {
> 	my $thing = $hash->{foo};
> 	if (UNIVERSAL::can($thing, "bar")

This should be:
     (UNIVERSAL::can($thing, "bar") || UNIVERSAL::can($thing, "AUTOLOAD")

There's a discussion about it in the archives.

http://lists.webarch.co.uk/pipermail/petal/2002-September/000137.html


> As you can see it doesn't test for an ARRAY ref because the key was not 
> numeric. If the key was numeric then it would replace the object test with an 
> array test.

Smart...


> Unfortunately it's messy having these directly in the source code. It could be 
> replaced by a call to a subroutine instead but that would have some extra 
> overhead. It's a pity Perl can't inline subroutines, then it'd be the best of 
> both worlds.

I think it's fine. It's not like you're going to have to maintain the 
Perl code which gets produced anyway! The only thing that scares me a 
little bit is that generating Perl code from Perl code doesn't look so 
good :(


>>Plus it looks really bad I think.
> Complain to Larry Wall about that one ;-) it's based on Perl.

And that's exactly the reason for which I use templates. I do _NOT_ want 
them to look like Perl! Personally I love Perl syntax BUT I also think a 
lot of people (esp. the ones who are writing / maintaing templates) 
don't necessarily see it that way :)


> It's an extension that uses characters that aren't reserved for any other 
> purpose so people can ignore it if they want. I suppose, depending on the 
> template the benefits can be anywhere from very large to very small.

OK if you see it as something optional that CAN be used when you need to 
squeeze out the extra little bit of performance I think it's fine.


> Luckily enough your code is very easy to follow and Petal was built for easy 
> extension,

Wow! Someone managed to understand my Perl code!
I'm gonna frame this sentence :)


Cheers,
Jean-Michel.



More information about the Petal mailing list