Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:59861 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35814 invoked from network); 13 Apr 2012 08:29:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Apr 2012 08:29:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=charlie@charliesomerville.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=charlie@charliesomerville.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain charliesomerville.com from 74.125.82.42 cause and error) X-PHP-List-Original-Sender: charlie@charliesomerville.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:54812] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/00-35770-1E3E78F4 for ; Fri, 13 Apr 2012 04:29:22 -0400 Received: by wgbds11 with SMTP id ds11so5496341wgb.5 for ; Fri, 13 Apr 2012 01:29:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=PngQg0NczjuaUqRX9sbAQVgrGVM3sj4M2Pj1Gb0y1Tc=; b=YIoKdGP0vhIIsEOdskD0uw2tyFvEqwZfWOHNtdb4cUy6HLTyPcINrE2nMxoWmhxdWa 3jr4GVw/9ot+0mfOAlLZWC6aMfSIroGnMoHNnJ77wUeks7SPw2Lb7Kpk0C74gGCiMCaT 4eo8slZFI3XRTMTE3APsvU5dsdNfOaRDV6hr93EawrePN8kh6RGYMmiqKusj034TZ5UU qYLrYzimSS5e2HxQ0wQ35ffTbYKSHTnr/NnVHNGikRsGqtJQcHRLJ6FFpPZN6Z2N7ehx T3S6Dd9jzuW9isTC1XL+wtKAHndAzzje0BG/rhpow7r0JNpQEBs94aKAVhxePmzzVvEz UUow== MIME-Version: 1.0 Received: by 10.180.82.132 with SMTP id i4mr2534355wiy.12.1334305758715; Fri, 13 Apr 2012 01:29:18 -0700 (PDT) Received: by 10.180.145.167 with HTTP; Fri, 13 Apr 2012 01:29:18 -0700 (PDT) Received: by 10.180.145.167 with HTTP; Fri, 13 Apr 2012 01:29:18 -0700 (PDT) In-Reply-To: References: <4F87DF77.7040608@mail.by> Date: Fri, 13 Apr 2012 18:29:18 +1000 Message-ID: To: Yasuo Ohgaki Cc: internals@lists.php.net, Verbitsky Alexander Content-Type: multipart/alternative; boundary=f46d0443066cc51e1104bd8b44eb X-Gm-Message-State: ALoCoQnjJE8N3D9f1y3UDIyPh0HlStMluA5Lk85JBTt2TwKzyVS3usHjpZWN5N8i7gkrxe06xQZu Subject: Re: [PHP-DEV] [RFC] Allow "use( $longname as $alias)" syntax for closures declaration From: charlie@charliesomerville.com (Charlie Somerville) --f46d0443066cc51e1104bd8b44eb Content-Type: text/plain; charset=UTF-8 I'm at a bit of a loss as to why Laruence is claiming that allowing closures to implicitly access variables in the outer scope requires duplicating the symbol table. Is there any technical reason why it's not possible for scopes to retain a pointer to their parent scopes so variables can be looked up that way? On Apr 13, 2012 6:20 PM, "Yasuo Ohgaki" wrote: > Hi, > > 2012/4/13 Verbitsky Alexander : > > On 04/12/2012 06:38 PM, Laruence wrote: > >> > >> Hi: > >> I have made a RFC to allow user use T_AS in the closure > declaration, > >> like: > >> > >> function () use($long as $l,&$long as $r) { > >> > >> } > >> > >> here is the RFC: https://wiki.php.net/rfc/useas > >> > >> any ideas? thanks > >> > > Closure is a functional literal that can pull with itself all variables > > visible in current scope where it was created. For my opinion using > keyword > > 'use' is not necessary and i would have removed it. If you need different > > name of variable maybe you need anonymous function. > > > > You might be used to other language's scoping, but > this is the way PHP works. > > Named function cannot do this, but anyway > function FUNC($a, $b, $c) uses ($d, $e, $f) {} > is like > function FUNC($a, $b, $c) { global $d, $e, $f; } > > I would rather have this. > function FUNC($a, $b, $c) uses ($d, $e, $f) {} > Then it would be consistent with anonymous function. > > There are methods, so we should be careful though. > > Regards, > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --f46d0443066cc51e1104bd8b44eb--