Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:3716 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76559 invoked from network); 4 Aug 2003 11:31:29 -0000 Received: from unknown (HELO flock1.newmail.ru) (212.48.140.157) by pb1.pair.com with SMTP; 4 Aug 2003 11:31:29 -0000 Received: (qmail 14864 invoked from network); 4 Aug 2003 11:31:09 -0000 Received: from unknown (HELO JUNGLE) (xi.newmail.ru@217.118.74.9) by smtpd.newmail.ru with SMTP; 4 Aug 2003 11:31:09 -0000 Date: Mon, 4 Aug 2003 18:33:00 +0600 X-Mailer: The Bat! (v1.62q) Personal Reply-To: Simeon Koptelov X-Priority: 3 (Normal) Message-ID: <332149432.20030804183300@newmail.ru> To: internals@lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: RE:Re[2]: [PHP-DEV] Re: hook cast_object handler in userspace From: xi@newmail.ru (Simeon Koptelov) Hello Cristiano, Monday, August 4, 2003, 8:45:20 AM, you wrote: >> CD> Should the method be named "to_string()", "tostring()" or CD> "__tostring()" ? Maybe the __tostring() will be the best because few naming conventions for methods exist. Some people prefer C-like some_method(), some like Java-like someMethod() etc. But there is already in PHP5 pre-defined methods like __clone, __construct, __destruct so the "__tostring" name will be expected by user. The "__to_string" will also be though. I have seen no "__" methods with names having two words so this variants are equal from my point of view. CD> I modified the code to just call to_string if the object implements the CD> "printable" interface. The printable is IMHO definetly not good name for such interface. When user sees the "implements Printable" he expects methods like print(), println() etc. that do something, not return strings. I can't name this interface better though. Maybe it will be better to have this method in all classes and define default behavior such as existing ( string )$object cast? -- Best regards, Simeon mailto:xi@newmail.ru