Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72953 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62689 invoked from network); 5 Mar 2014 22:46:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2014 22:46:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=narf@devilix.net; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=narf@devilix.net; sender-id=pass Received-SPF: pass (pb1.pair.com: domain devilix.net designates 209.85.213.49 as permitted sender) X-PHP-List-Original-Sender: narf@devilix.net X-Host-Fingerprint: 209.85.213.49 mail-yh0-f49.google.com Received: from [209.85.213.49] ([209.85.213.49:38310] helo=mail-yh0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/71-55049-159A7135 for ; Wed, 05 Mar 2014 17:46:43 -0500 Received: by mail-yh0-f49.google.com with SMTP id z6so1845006yhz.8 for ; Wed, 05 Mar 2014 14:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=devilix.net; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Oa856OARpHnap3jD6R0tfOb+e27fNRACHS4mMZcRWEQ=; b=GoZVSEjeu1PTGgZJMWvy3ncZOgnwpg8VjPh2fE8hRiY3EzK4HJWSF01dScRngBnVBw uvNqfKyOQIfS0xYNnvzWExBZ6GzPz4bRGlsddj/UqF+VdXsnZZGEC4AtxIEJtVtRk4ti 1L46wpcGPAtW3bX6bWrwBOPv6x9BwvstERlVc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Oa856OARpHnap3jD6R0tfOb+e27fNRACHS4mMZcRWEQ=; b=Qaka7b2LvaEGgiaSdTk2XEXSoyXTPKCATuipEPukiEBKxBhhPBxXhC4i3SjBk6eeJl R8LbFh+cGqLN3nx+wWivz/KMQzLdHRVzvzl/c3OHCcrlhag3CMn65VWYG0rtfhS5j5Ty IRMPRL6FOg+heUVaP9NTD8qS5ywG8/wGCDSLIEO2SY/O5Uiop9iJClTLUVv6/N5YOeRf gsQeMq9fYLQs82Dz8Hi8EHVfMf+iI9n/dkLRM/NQbjNxdu9t+z0M6T4L983ES66mEKCd dvJD5UPGwtRln9eWKgXDysbSlrqQeLsR9pp2UJ+VNaesJUH8q7GnkvYRDtObTEsMezBc gSWw== X-Gm-Message-State: ALoCoQmBQJga2bbk9po8W5kGnv/wrHTxewwKB6XhbKmCau1BLoX3/szDUZQbjZfQkCLBSQuhIG8N MIME-Version: 1.0 X-Received: by 10.236.122.99 with SMTP id s63mr10350442yhh.19.1394059598453; Wed, 05 Mar 2014 14:46:38 -0800 (PST) Received: by 10.170.188.139 with HTTP; Wed, 5 Mar 2014 14:46:38 -0800 (PST) In-Reply-To: <5317A479.4020102@sugarcrm.com> References: <5317A479.4020102@sugarcrm.com> Date: Thu, 6 Mar 2014 00:46:38 +0200 Message-ID: To: Stas Malyshev Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] T_AS in closures From: narf@devilix.net (Andrey Andreev) Hi, On Thu, Mar 6, 2014 at 12:26 AM, Stas Malyshev wrote: > Hi! > >> I was clicking on bugs.php.net/random today and I came across #54888, >> which is a feature request for the following syntax: >> >> $foo = 'whatever'; >> $bar = function() use ($foo as $baz) { /* use $baz here */ }; > > What this allows to do that simple $baz = $foo and use $baz wouldn't do? > I think adding syntax that does not substantially expand what you can do > is not right. It just makes language larger and harder to learn and > understand. To answer your question: nothing, except that $baz will only exist in the scope of the anonymous function. But this is not about something that can't be achieved with existing features, it's about cleaner code and to some extent - consistency with T_AS in foreach(), traits, namespaces; and also how regular functions would have local-scope names for variables that are passed to them.