[Petal] compiled expression (again)

Jean-Michel Hiver jhiver at mkdoc.com
Thu Jun 19 12:25:32 BST 2003


> It's a decision by me but it wouldn't be a big deal to wrap all accesses in 
> some code to prevent this happening.
> 
> Petal currently generates code like this
> 
> $res .= $hash->get( "user" );
> 
> get() translates undef to "", thus avoiding the warning.
> 
> The new one generates this
> 
> $res .= $hash->{"user"};
> 
> so if $hash->{"user"} is undefined then we get the warning.
> 
> Easy solutions are to to generate code like this
> 
> $res .= do{ my $value = $hash->{"user"}; defined $value ? $value : "" };
> 
> or
> 
> $res .= define($hash->{"user"});

Or maybe $res .= defined $hash->{"user"} ? $hash->{"user"} : "";

If only we'd have the ?? operator that Larry refused to implement :)


> Either of these would be very easy to do but obviously there is a speed 
> penalty.

Well, I'm sure it would still be very acceptable speed-wise. I think it
would be a much better option since it's more inline with the way things
currently work.


Cheers,
-- 
Building a better web - http://www.mkdoc.com/
---------------------------------------------
Jean-Michel Hiver
jhiver at mkdoc.com  - +44 (0)114 255 8097
Homepage: http://www.webmatrix.net/


More information about the Petal mailing list