Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45310 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7693 invoked from network); 18 Aug 2009 09:46:50 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Aug 2009 09:46:50 -0000 Authentication-Results: pb1.pair.com header.from=ville.jungman@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ville.jungman@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.219.216 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ville.jungman@gmail.com X-Host-Fingerprint: 209.85.219.216 mail-ew0-f216.google.com Received: from [209.85.219.216] ([209.85.219.216:59667] helo=mail-ew0-f216.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1C/E3-19981-8887A8A4 for ; Tue, 18 Aug 2009 05:46:48 -0400 Received: by ewy12 with SMTP id 12so2949105ewy.24 for ; Tue, 18 Aug 2009 02:46:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=jZUQhm1t99HbZz6X2/HujCf2yB8VftBXSgzL36biYoY=; b=epo/O1XAMzFm0EQjtkaTKwumBvVBxqfOxSG6/8Bsdgo4PaZJmo/8U9C4qnaUF1PQkm ms+OQ22VIRLN1KIJ9gsxbUzszGzUfRJeSUNXtbbQ+FYU1SsQ15iriNVWKo/u4eGTNzL3 Imb21omi6N58nf8/ND/bXfH6O4PVYZ+TWlJcE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=gw/qy5sD710J72ELcbNXuQFTcyYAG2SAQbqQ4S+BK0iS4l3it1NBBsPJw4/GlsmLeL WjzxV9ux+QJXlVOsiWR2DxLQrHWgFn1jOPqve7/645cdS0J6ApJV8gJ3Bvv8/4UJKor/ wr2ivHemjvYI79VbxPrDsEz8iP2Cqj68/4zYw= MIME-Version: 1.0 Received: by 10.216.87.68 with SMTP id x46mr1218001wee.2.1250588802394; Tue, 18 Aug 2009 02:46:42 -0700 (PDT) In-Reply-To: <1250532126.2446.16.camel@guybrush> 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> Date: Tue, 18 Aug 2009 12:46:42 +0300 Message-ID: <50c696b0908180246u5a713c87u12bc1a09e7a46efb@mail.gmail.com> To: php-dev List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: SOAP_MARSHAL_DATETIME (or: bug #44383) From: ville.jungman@gmail.com (Ville Jungman) 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