Date: 11/23/00
- Next message: David Muse: "Re: [PHP-DEV] Input paramters..."
- Previous message: André Langhorst: "Re: [PHP-DEV] Passing-by-reference"
- In reply to: Andi Gutmans: "Re: [PHP-DEV] Passing-by-reference"
- Next in thread: André Langhorst: "Re: [PHP-DEV] Passing-by-reference"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 23 Nov 2000, Andi Gutmans wrote:
> At 03:11 PM 11/23/00 -0500, Ignacio Vazquez-Abrams wrote:
> >
> >c) Throw an error. More than likely this will indicate a coding problem, and
> >just passing a copy will cause a developer to scratch her head and say
> >"WTF?" for several months while trying to figure out the problem(s). Leaving
> >behavior as undefined will just cause memory corruption problems for sloppy
> >developers, which is what we want to get away from in the first place.
>
> Throwing an error is a problem because we can't really detect it. With my
> patch the undefined behavior will not cause memory corruption anymore but
> will either throw an error or continue working (i.e. undefined).
> In the manual it would say something like:
> Receiving arguments by reference:
> ----------------------------------------
> Three ways of passing an argument to a function which wants to receive its
> argument by reference:
> a) foo($a) // Passing a variable
> b) foo(new foo()) // Passing a newly created object
> c) foo(MyFactory()) // Where MyFactory() is explicitly defined to return
> the return value by reference, which is done by defining it as "function
> &MyFactor(){...}"
>
> ALL OTHER ARGUMENT PASSING RESULTS IN UNDEFINED BEHAVIOR!
>
> How's that? :)
> Andi
>
> Andi
> ---
> Andi Gutmans <andi <email protected>>
> http://www.zend.com/
>
Hmm. I guess the only way to detect something like that would be to have
another "unreferrable" field on a value and set it when the value is a
constant expression (e.g., "Hello, world", 5+4, a value returned from a
non-reference-returning function, etc.), and clear it when assigned to a
variable. A feature for 5.0 perhaps?
-- Ignacio Vazquez-Abrams <ignacio <email protected>>-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: David Muse: "Re: [PHP-DEV] Input paramters..."
- Previous message: André Langhorst: "Re: [PHP-DEV] Passing-by-reference"
- In reply to: Andi Gutmans: "Re: [PHP-DEV] Passing-by-reference"
- Next in thread: André Langhorst: "Re: [PHP-DEV] Passing-by-reference"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

