On Tue, Sep 02, 2003 at 11:59:29AM +0200, Marcus Brger wrote:

> JP> Attached is a fairly simple (and rough) patch that adds support for a
> JP> "special" __string() object method to ZE2.  I wrote it for fun, but I
> JP> thought there might be general interest in the idea, so I'm posting it
> JP> here.  The idea is inspired by Python's __str__ method [1].
> 
> First why not name it toString() since for now we have consensus on sudlyCaps.
> But i didn't bother with names yet when i made this patch:
> http://marcus-boerger.de/php/ext/ze2/ze2-iterators-20030902.diff.txt

I chose '__string' to follow the existing convention for "special"
method names (e.g. __construct, __clone, __call).  Also, I suspect
that many developers are already using toString() methods in their
classes, and I'm not sure we want to use them directly with having
them think about the semantics of their decision first.
 
> Second i think you should use the cast facility like i did in my patch.
 
I looked at the cast facility briefly and decided not to use it
because it meant including a new zend_std_* implementation for casting
(that function entry is currently NULL in zend_object_handers.c).

Admittedly, I wasn't comfortable at the time with writing a universal
casting handler, and because I only wanted to deal with string
conversions, I decided to just implement it as a separate dedicated
function entry.

-- 
Jon Parise ([EMAIL PROTECTED]) :: The PHP Project (http://www.php.net/)

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to