Re: Re: SOAP_MARSHAL_DATETIME (or: bug #44383)

From: Date: Tue, 18 Aug 2009 09:46:42 +0000
Subject: Re: Re: SOAP_MARSHAL_DATETIME (or: bug #44383)
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-45310@lists.php.net to get a copy of this message
1) it would be fun if code recycling was easier. nowadays extracting a function from code is sometimes complicated if you need to reuse it elsewhere. For example you have this ... while($numbers as $value){ while(...){ while(...){ ... do_something_with($value); ... } } } ... but you would like to use the inner loop also elsewhere. Just define it as a function ... while($numbers as $value){ while(...){ while(...){ do_something_with($value); do_something_with($value + 1); } as function inner_loop($value); } } ... and go ... inner_loop(3); Or you have a function below and would like to use only the if-part elsewhere. Again define that as a function: function something($value){ something(); foreach(...){ if(...){ do_something_with($value); do_something_with($value + 1); } as function snippet($value); } something(); } ... and call it ... snippet(3); --- 2) i think it might be useful if all php internal commands returned some value(s) something like this could do ... while( if($x){ return array(1,2); }else{ return array(3,4,5); } as $value ){ do_something_with($value); } ... or even ... $selection_array = while( if($x){ return array(1,2); }else{ return array(3,4,5); } as $value ){ do_something_with($value); return if($value == 2 || $value == 4){ return $value; } } ; this would make code more straightforward and easier to understand (when you get used to it). and enables "a maximum degree of recursivability that can lead to impressive solutions some areas". also think about pipes in shell. (the return idea is stolen from postgres pl/pgsql. loop commands (while, foreach etc) return always arrays.) see also: http://www.rebol.net/r3blogs/0024.html http://www.mail-archive.com/beginners@perl.org/msg47298.html http://www.postgresql.org/docs/8.0/interactive/plpgsql-control-structures.html --- Ville

« previous php.internals (#45310) next »