Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45311 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43885 invoked from network); 18 Aug 2009 14:11:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Aug 2009 14:11:36 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.133 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.133 mailout1.netbeat.de Linux 2.6 Received: from [83.243.58.133] ([83.243.58.133:57363] helo=mailout1.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/93-22194-696BA8A4 for ; Tue, 18 Aug 2009 10:11:36 -0400 Received: (qmail 31938 invoked by uid 89); 18 Aug 2009 14:39:00 -0000 Received: from unknown (HELO ?192.168.178.26?) (postmaster%schlueters.de@84.154.99.156) by mailout1.netbeat.de with ESMTPA; 18 Aug 2009 14:39:00 -0000 To: Ville Jungman Cc: php-dev List In-Reply-To: <50c696b0908180246u5a713c87u12bc1a09e7a46efb@mail.gmail.com> References: <4A6EE1BF.8080409@zend.com> <4A6F027B.3040608@zend.com> <4A6F3211.40801@sci.fi> <467D68D2-E465-4A25-B123-655A632B17AD@bitextender.com> <4A81145F.6050504@zend.com> <4A814259.1040308@zend.com> <1250532126.2446.16.camel@guybrush> <50c696b0908180246u5a713c87u12bc1a09e7a46efb@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 18 Aug 2009 16:11:02 +0200 Message-ID: <1250604662.2429.3.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.26.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: SOAP_MARSHAL_DATETIME (or: bug #44383) From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, 1) please don't abuse another thread for something completely unrelated, that makes tracking things really hard. 2) Most of you want should be doable with 5.3's anonymous functions/closures. 3) More than that isn't really planned at the moment. johannes On Tue, 2009-08-18 at 12:46 +0300, Ville Jungman wrote: > 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 >