Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread Stuart
2009/7/6 Lupus Michaelis mickael+...@lupusmic.org:  Hi,  I would like to know if I am alone to be shoked by this : == 8 == function foo( $bar = null) { } foo() ; // runs foo(null) ; // raise an error == 8 ==  Why the default value to null for a reference is allowed ? Is it a bug, a

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread Lupus Michaelis
Stuart a écrit : You appear to be using the definition of null that comes from the world of C. I didn't. The point is I'm allowed to set a default value to null for a referenced parameter (what I can do in C for a pointer, so I knew it). I'm happy PHP raises an error on foo(null) ;

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread Stuart
2009/7/6 Lupus Michaelis mickael+...@lupusmic.org: Stuart a écrit : You appear to be using the definition of null that comes from the world of C.  I didn't. The point is I'm allowed to set a default value to null for a referenced parameter (what I can do in C for a pointer, so I knew it).

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread Lupus Michaelis
Stuart a écrit : The whole point of default arguments is for it to use that argument if none is passed. It is not the point too. What makes you think not passing an argument to that function should raise an error? Maybe because in my example, the provided value is not a valuable value

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread David Otton
2009/7/6 Lupus Michaelis mickael+...@lupusmic.org:  I'm happy PHP raises an error on foo(null) ;  I'm in trouble when foo() doesn't.  The actual question is : why PHP doesn't raise an error ? This functionality (default values for passed-by-reference parameters) was added in PHP5. The

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread David Otton
2009/7/6 Lupus Michaelis mickael+...@lupusmic.org: David Otton a écrit : So there's some serious impedance mismatch going on there to make both features to work together. Just think of the default value as something I can overwrite, eg:  Thanks for this smart explanation. It shines my day.

Re: [PHP] Function parameter passed by reference with default value to null

2009-07-06 Thread Lupus Michaelis
David Otton a écrit : So there's some serious impedance mismatch going on there to make both features to work together. Just think of the default value as something I can overwrite, eg: Thanks for this smart explanation. It shines my day. -- Mickaël Wolff aka Lupus Michaelis