Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:71667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85863 invoked from network); 28 Jan 2014 12:32:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2014 12:32:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; 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:57898] helo=mail-qc0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/EC-01140-D43A7E25 for ; Tue, 28 Jan 2014 07:32:13 -0500 Received: by mail-qc0-f176.google.com with SMTP id e16so395754qcx.35 for ; Tue, 28 Jan 2014 04:32:10 -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=ud5ixMNDZlmnfVG/jMz79MuSkDBAR/0HKFqI014JVy4=; b=WJ8WIRUFvQPXRb8vGQvjE8IS92PdzdhPZuIMhlvqQCt5E33Qa+M2R4v+//KPMnGKGv QOczBGn4TFhA2lORKnjsYmcd60wViFcO9emiTubzEcLZVVHuqDK8YbN0G+xqQo2arYSi 4fl9eKyTm0ncKq7+uIWzXNhBhiejysvhJ3c+Q2i4zEhYEmt/u1yAgA83Lhm718nV0U8E FmnXRqiHo76zxnHeuuzSaMzw3Jz+bnPUMMGQtWbA3pAa6PQT34OqpYmArXSnXUV9Wg7O B7+vcvLH/Gqg2EyPfaEJNHIRaumOTYT0zUzmE/1UVg0wnEqtRHyogGPNWr+7Rw6zlfn9 SUWQ== X-Received: by 10.224.137.66 with SMTP id v2mr1752663qat.104.1390912330282; Tue, 28 Jan 2014 04:32:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.87.151 with HTTP; Tue, 28 Jan 2014 04:31:30 -0800 (PST) In-Reply-To: <1796143171.126442.1390903281925.open-xchange@app2.ox.registrar-servers.com> References: <1796143171.126442.1390903281925.open-xchange@app2.ox.registrar-servers.com> Date: Tue, 28 Jan 2014 13:31:30 +0100 Message-ID: To: Andrea Faulds Cc: PHP internals list Content-Type: multipart/alternative; boundary=001a11c2ccd45c3bd104f1070359 Subject: Re: [PHP-DEV] Lexical scoping From: krebs.seb@gmail.com (Sebastian Krebs) --001a11c2ccd45c3bd104f1070359 Content-Type: text/plain; charset=ISO-8859-1 2014-01-28 Andrea Faulds > Good morning, > > Perhaps a future version of PHP (PHP 6? 5.7?) could have lexical scoping > 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 = 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 additional keyword. It is only to avoid, that you accidentally interfere with outers scope variables? If it is hard to track these variables, maybe your method/function is too big. Regarding your example: foreach ($array as &$a) { $a = 3; } $a = null; // $a not a reference anymore. Problem solved :) 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 --001a11c2ccd45c3bd104f1070359--