Hello Simeon,

Monday, August 4, 2003, 2:33:00 PM, you wrote:

SK> Hello Cristiano,

SK> Monday, August 4, 2003, 8:45:20 AM, you wrote:

>>> CD> Should the method be named "to_string()", "tostring()" or
CD>> "__tostring()" ?

SK> Maybe the __tostring() will be the best because few naming
SK> conventions for methods exist. Some people prefer C-like some_method(), some
SK> like Java-like someMethod() etc. But there is already in PHP5
SK> pre-defined methods like __clone, __construct, __destruct so the
SK> "__tostring" name will be expected by user. The "__to_string" will
SK> also be though. I have seen no "__" methods with names having two
SK> 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.

SK> The printable is IMHO definetly not good name for such interface. When
SK> user sees the "implements Printable" he expects methods like
SK> print(), println() etc. that do something, not return strings.
SK> I can't name this interface better though.
SK> Maybe it will be better to have this method in all classes and define
SK> default behavior such as existing ( string )$object cast?

Good comments on the naming issue.
>From the proposed "__tostring" and "__to_string" i'd prefer the latter.

-- 
Best regards,
 Marcus                            mailto:[EMAIL PROTECTED]


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

Reply via email to