Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71671 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98683 invoked from network); 28 Jan 2014 14:06:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2014 14:06:29 -0000 Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.176 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.216.176 mail-qc0-f176.google.com Received: from [209.85.216.176] ([209.85.216.176:60686] helo=mail-qc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/5F-01140-369B7E25 for ; Tue, 28 Jan 2014 09:06:27 -0500 Received: by mail-qc0-f176.google.com with SMTP id e16so565276qcx.7 for ; Tue, 28 Jan 2014 06:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=cBnK9PgpKcd4gRfl2V0drxVzBPAthbX1de+chbKsQdg=; b=lziZfnCkbpHLCQoHYKyZRB1BRtQbLjQPfx5hkzIP8Z6BTQRkUxpKMGVetG8LNn2Fvl yvt12D7F9pmQc1J7lT0cjJtBE9uMyKYGsuKjk6j0za9HsgaRjnEJL78TVucntYK9ifPo Y8elluYevQAY/GmhDzW2DXBkJUE3kZCmGF+Ix9T/FrCyliOb9K8reSRQ69ZSajLEUqNx KHPjgYEWcXDMGc7NdCw8Ygvvfo9n5EbwOgCg/opfBMdFIIXU+8WVXuEIcQbLGcmv1mO8 bw7Pm72ZFW2Y8BUTK51zztvkJ11yAo0EvEa+tGfaxfMcWKmNuzx6mHWhlknSCabWXdYm V3/w== X-Received: by 10.224.137.66 with SMTP id v2mr2512291qat.104.1390917962755; Tue, 28 Jan 2014 06:06:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.87.151 with HTTP; Tue, 28 Jan 2014 06:05:22 -0800 (PST) In-Reply-To: References: <1796143171.126442.1390903281925.open-xchange@app2.ox.registrar-servers.com> Date: Tue, 28 Jan 2014 15:05:22 +0100 Message-ID: To: Lazare Inepologlou Cc: Andrea Faulds , PHP internals list Content-Type: multipart/alternative; boundary=001a11c2ccd414f1f504f1085389 Subject: Re: [PHP-DEV] Lexical scoping From: krebs.seb@gmail.com (Sebastian Krebs) --001a11c2ccd414f1f504f1085389 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 2014-01-28 Lazare Inepologlou > > 2014-01-28 Sebastian Krebs > > 2014-01-28 Andrea Faulds >> >> > Good morning, >> > >> > Perhaps a future version of PHP (PHP 6? 5.7?) could have lexical scopi= ng >> > with a >> > "let" keyword? At the very least, it would make foreach() with a >> reference >> > less >> > of a problem: >> > >> > foreach ($array as let &$a) { >> > $a =3D 3; >> > } >> > // $a is not in this scope - no need to worry about accidentally >> > changing >> > last array item >> > >> > Any thoughts? >> > >> >> Hi, >> >> My 2 cents: That is a very minor improvement at the cost of an additiona= l >> keyword. It is only to avoid, that you accidentally interfere with outer= s >> scope variables? If it is hard to track these variables, maybe your >> method/function is too big. >> >> > I agree. > > >> Regarding your example: >> >> foreach ($array as &$a) { >> $a =3D 3; >> } >> $a =3D null; // $a not a reference anymore. Problem solved :) >> >> > Problem not solved. You have just changed the last element of $array... > This is the exact problem that was to be avoided. > Touche ;) then use unset(). This time I tried it before: http://codepad.viper-7.com/lOx1XL > > > Lazare INEPOLOGLOU > Ing=E9nieur Logiciel > > > >> Regards, >> Sebastian >> >> >> > -- >> > Andrea Faulds >> > http://ajf.me/ >> > >> > -- >> > PHP Internals - PHP Runtime Development Mailing List >> > To unsubscribe, visit: http://www.php.net/unsub.php >> > >> > >> >> >> -- >> github.com/KingCrunch >> > > --=20 github.com/KingCrunch --001a11c2ccd414f1f504f1085389--