You are here: Re: A PHP fork « PHP Programming Language « IT news, forums, messages
Re: A PHP fork

Posted by Chung Leong on 07/07/06 21:06

Mladen Gogala wrote:
> Chung, you're one of my favorite PHP masters and I learned few things from
> you on this group, but the work you're doing has already been done. PHP
> runkit extension, by Sara Golemon, has this possibility:
>
> RUNKIT_IMPORT_OVERRIDE (integer)
>
> runkit_import() flag indicating that if any of the imported functions,
> methods, constants, or properties already exist, they should be
> replaced with the new definitions. If this flag is not set, then any
> imported definitions which already exist will be discarded.
>
> This sounds very much like overloading to me.

No, actually it's not even close. The runkit just exposes
functionalities in the Zend engine. Overwriting a function is not the
same as overloading it. Wikipedia has a good explanation
http://en.wikipedia.org/wiki/Function_overloading.

What Polar supports is a type of dynamic dispatch, controlled by the
types of the arguments. I call it Sematic Polymorphism. It's similiar
to polymorphism in OOP, except functions are bound to meanings not
objects.

Say we have the following functions:

<?

function SaveObjectToDatabase($object:Object, $db:MysqlDB) {
}

function SaveObjectToDatabase($article:Article, $db:MysqlDB) {
}

?>

Both functions are bound to the meaning of "saving an object to a MySQL
database." The second function is bound to a more specific meaning,
that of "saving an object of the class Article to a MySQL database." In
OOP terms we would say that the second meaning is a descendant of the
first. The relationship isn't stated explicitly, but it's understood.

It's neat idea. There're also a host of other features which I think
are pretty interesting. Pragmas for example. Or Flex case identifiers.


If you have time, take a look at the demo program. You can download it
here:
http://sourceforge.net/project/showfiles.php?group_id=171247

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация