> What the current idea would be is an implicit casting (as I understood it right).
Yes, exactly. > This won't make it easy passing a variable as reference. Type casting combined with passing by reference is problematic in many ways. Just an example: fuction foo( string & $buffer) { ... } foo( $my_buffer ); Here, $my_buffer has just been declared, so it is null. Should this be an error? I don't know! So, I think that that passing by reference should not be (immediately) supported. Lazare INEPOLOGLOU Ingénieur Logiciel 2012/3/9 Simon Schick <simonsimc...@googlemail.com> > 2012/3/9 Lazare Inepologlou <linep...@gmail.com> > > > > Yes, like that, only better. Since automatic type casting is central in > > PHP, as this is evident after all this discussion, I believe that it > > should > > be better supported. There are two thinks that I would like to see here: > > > > 1. No more magic methods, please. > > 2. It should cover (eventually) casting to and from any type. > > > > :-) > > > > Lazare INEPOLOGLOU > > Ingénieur Logiciel > > > > Hi, Lazare > > As you mentioned it in another thread, I like the idea of C# you described > ... > Draw a line between explicit and implicit casting. > > What the current idea would be is an implicit casting (as I understood > it right). > Let me just repeat your examples: > > 2012/3/7 Lazare Inepologlou <linep...@gmail.com> > > function test_float( float test ) { ... } > > test_float( 1.0 ); // ok > > test_float( 1 ); // implicit int to float cast, ok > > > > function test_array( array test ) { ... } > > test_array( array() ); // ok > > test_array( 1 ); // no implicit int to array cast, error! > > test_array( (array)1 ); // explicit int to array cast, ok > > An explicit type-cast should be always possible and try to get the > very last bit of useful information out of the given bunch. Here it > makes sense to have magic functions for integer, float, string etc. > > But as we're here talking about an implicit casting when passing a > class to a function, I don't like the idea of calling the > magic-functions if you paste a class in here as it changes the content > of the variable. This won't make it easy passing a variable as > reference. If you just switch to another type, you can afterwards do > whatever you was able to do before. > > Bye > Simon >