Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c

From: Date: Mon, 01 Dec 2003 06:16:02 +0000
Subject: Re: Re: [ZEND-ENGINE-CVS] cvs: ZendEngine2 / zend_API.c
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-5846@lists.php.net to get a copy of this message
On Sun, Nov 30, 2003 at 01:08:33AM +0200, Andi Gutmans wrote: > Wrong. __toString() isn't supposed to work in every case the engine expects > a string. > You'd probably also want $obj[3] to work as a string offset? > In this case, maybe we should rename __toString to __toPrintable, because I > think Marcus' patch is asking for trouble. Python goes as far as to define two special methods for representing objects as strings: __repr__( self) Called by the repr() built-in function and by string conversions (reverse quotes) to compute the ``official'' string representation of an object. If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment). If this is not possible, a string of the form "<...some useful description...>" should be returned. The return value must be a string object. If a class defines __repr__() but not __str__(), then __repr__() is also used when an ``informal'' string representation of instances of that class is required. This is typically used for debugging, so it is important that the representation is information-rich and unambiguous. __str__( self) Called by the str() built-in function and by the print statement to compute the ``informal'' string representation of an object. This differs from __repr__() in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead. The return value must be a string object. -- Jon Parise (jon@php.net) :: The PHP Project (http://www.php.net/)

« previous php.internals (#5846) next »