A PHP fork

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
For the past few months I've been working on a fork of PHP from the
version 4 source code. I call the new dialect "Polar." It's different
from PHP 5 in that it's a procedural-centric language. One of the key
additions is function overloading, which lets you do polymorphism

function db_query($sql, $db:MySQLDB) {
   /* MySQL-specific code here */

function db_query($sql, $db:PostgresDB) {
   /* Postgres-specific code here */

Aside from that there are many other enhancements like a float-based
datetime type and a Unicode string type. It's pretty neat. You can find
more information at http://www.polarwiki.net /. The site is hosted on
the Polar itself, though it's running mostly PHP apps. I have built a
standalone Windows program that demonstrate the new features. You can
download it at the the web site.

Right now I'm just an army of one. I'm definitely looking for more
help. Drop a note in the message forum if you interested. Any comments
are welcomed too.

Re: A PHP fork

Function overloading is a feature a lot of people want.  Why not merge
this with the existing PHP code? I'm sure they would love to have
someone with your talent contributing!

Chung Leong wrote:
Quoted text here. Click to load it

Re: A PHP fork

Richard Levasseur wrote:
Quoted text here. Click to load it

Function overloading in Polar only works for standalone functions, not
class methods. As the intention here is to move away from OOP, that's
fine. I doubt that that's a limitation people would accept, since OOP
is the direction that PHP is heading.

Overloading in a dynamically typed language is rather different from
overloading in a strongly typed language like C++. In the latter,
resolution of function calls happens at compile time. In the former, it
has to happn at runtime. Overloading here is a form of dynamic
dispatch, akin to calling virtual methods on an object. Having two
dynamic dispatch mechanisms working in unison is probably too

Re: A PHP fork

Wow!  Nice work man!

I'm a big fan of OO myself, but as already mentioned there are a lot of  
people out there wanting more from PHP in the procedural programming  

Good on you for taking the initiative to do this.


Chung Leong wrote:
Quoted text here. Click to load it

|OT| Polar, a PHP fork by Chung Leong (Was Re: A PHP fork)

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Re: A PHP fork

On Thu, 06 Jul 2006 13:48:23 -0700, Chung Leong wrote:

Quoted text here. Click to load it

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() 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.


Re: A PHP fork

Quoted text here. Click to load it

 That's just redefinition, not overloading...

Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: A PHP fork

Mladen Gogala wrote:
Quoted text here. Click to load it

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

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

Site Timeline