On Wed, 2007-01-03 at 17:49 +0000, Roman Neuhauser wrote:
>
> If you dare to use dynamic features in PHP you're begging to have your
> throat cut by some call to undefined method, or hop in to lala land with
> an "undefined member variable access" warning... If problems with the
> "dynamic typing" of PHP end in somewhat undynamic fatal errors, your
> only choice is to have all paths in the program statically verified,
> IOW, steer completely clear of the dynamic features. That'll be a
> terribly tedious job.
>
> You can do this in Python (completely safe and meaningful):
>
> def f(any):
> print "%s" % any
>
> You can even call any method on any object safely:
>
> def g(o):
> o.f()
>
> If o doesn't have a callable member called "f", you'll get an exception
> you can catch:
>
> def g(o):
> try:
> o.f()
> except AttributeError:
> print >> stderr, "oops!"
>
> The lack of global error handlers allows mixing of independently
> developed software, that's quite dynamic.
Not to get into this argument but the PHP equivalent is:
<?php
if( method_exists( $o, 'f' ) )
{
$o.f();
}
else
{
fprintf( stderr, 'oops!' );
}
?>
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php