Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:4351 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19615 invoked by uid 1010); 2 Sep 2003 15:45:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 19591 invoked from network); 2 Sep 2003 15:45:31 -0000 Received: from unknown (HELO blacksheep.csh.rit.edu) (129.21.60.6) by pb1.pair.com with SMTP; 2 Sep 2003 15:45:31 -0000 Received: from fury.csh.rit.edu (fury.csh.rit.edu [2001:470:1f00:135:a00:20ff:fe8d:5399]) by blacksheep.csh.rit.edu (Postfix) with ESMTP id 9D3B13D8; Tue, 2 Sep 2003 11:45:30 -0400 (EDT) Received: by fury.csh.rit.edu (Postfix, from userid 37404) id 814A91289; Tue, 2 Sep 2003 11:45:30 -0400 (EDT) Date: Tue, 2 Sep 2003 11:45:29 -0400 To: Marcus =?iso-8859-1?Q?B=F6rger?= Cc: internals@lists.php.net, engine2@lists.zend.com Message-ID: <20030902154529.GA13689@csh.rit.edu> Mail-Followup-To: Marcus =?iso-8859-1?Q?B=F6rger?= , internals@lists.php.net, engine2@lists.zend.com References: <20030902082910.GA29213@csh.rit.edu> <619505898.20030902115929@post.rwth-aachen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <619505898.20030902115929@post.rwth-aachen.de> Subject: Re: [PHP-DEV] [patch] __string() method From: jon@php.net (Jon Parise) 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 (jon@php.net) :: The PHP Project (http://www.php.net/)