Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:76409 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95136 invoked from network); 8 Aug 2014 00:45:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Aug 2014 00:45:05 -0000 Received: from [127.0.0.1] ([127.0.0.1:13587]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id F4/10-28981-09D14E35 for ; Thu, 07 Aug 2014 20:45:04 -0400 Authentication-Results: pb1.pair.com smtp.mail=prvs=329768eba1=jwatzman@fb.com; spf=unknown; sender-id=unknown Authentication-Results: pb1.pair.com header.from=jwatzman@fb.com; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain fb.com does not designate 67.231.153.30 as permitted sender) X-PHP-List-Original-Sender: prvs=329768eba1=jwatzman@fb.com X-Host-Fingerprint: 67.231.153.30 mx0b-00082601.pphosted.com Linux 2.5 (sometimes 2.4) (4) Received: from [67.231.153.30] ([67.231.153.30:4139] helo=mx0b-00082601.pphosted.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/41-14171-97A14E35 for ; Thu, 07 Aug 2014 20:31:53 -0400 Received: from pps.filterd (m0004077 [127.0.0.1]) by mx0b-00082601.pphosted.com (8.14.5/8.14.5) with SMTP id s780Uktk021661; Thu, 7 Aug 2014 17:32:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=6p9B/H8Hmg+wssnBwCDwW2vqeVl8+gFYRjA4zcZ0s8U=; b=MTT8CQaGVOYzaVZS8eOuyLE2bftPXF4Vx4foKrCt4m18gmnA3c3jsMlBJAGaIXc2edKz B05awW0FaCOZkqx3c5pBf2Y7/JsbvFpPg514RZ14Cs0+7C0k3gsQPhgXQqqu/n1EdX1k sri16F7hTOCpB/jPO7eHRmx17usKkHlF5kg= Received: from mail.thefacebook.com (mailwest.thefacebook.com [173.252.71.148]) by mx0b-00082601.pphosted.com with ESMTP id 1nmhyqrdrc-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=OK); Thu, 07 Aug 2014 17:32:21 -0700 Received: from PRN-MBX02-2.TheFacebook.com ([169.254.5.69]) by PRN-CHUB01.TheFacebook.com ([fe80::d5cc:849:f520:db6b%12]) with mapi id 14.03.0195.001; Thu, 7 Aug 2014 17:32:18 -0700 To: Andrea Faulds CC: Rowan Collins , "internals@lists.php.net" Thread-Topic: [PHP-DEV] [RFC] Closure::call and Function Referencing as Closures Thread-Index: AQHPr2UX6cWu/Jgb6EeTLZp+MQ2x55vAdcmAgABbUYCAAH23AIAAAi0AgAUGAgA= Date: Fri, 8 Aug 2014 00:32:17 +0000 Message-ID: References: <53DF2BED.10103@sugarcrm.com> <06F3EF08-21B1-49AD-9D9D-5043C69AC1D8@ajf.me> <53DFE1FC.5040206@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.16.4] Content-Type: text/plain; charset="Windows-1252" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52,1.0.27,0.0.0000 definitions=2014-08-07_08:2014-08-06,2014-08-07,1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 kscore.is_bulkscore=0 kscore.compositescore=0 circleOfTrustscore=78.4390864689233 compositescore=0.322287768733618 urlsuspect_oldscore=0.322287768733618 suspectscore=0 recipient_domain_to_sender_totalscore=20 phishscore=0 bulkscore=0 kscore.is_spamscore=0 recipient_to_sender_totalscore=0 recipient_domain_to_sender_domain_totalscore=2524143 rbsscore=0.322287768733618 spamscore=0 recipient_to_sender_domain_totalscore=2 urlsuspectscore=0.9 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1402240000 definitions=main-1408080004 X-FB-Internal: deliver Subject: Re: [PHP-DEV] [RFC] Closure::call and Function Referencing as Closures From: jwatzman@fb.com (Josh Watzman) [Andrea, please forward this to internals if you don't see my message appea= r there in a few hours; as you know, FB is working through issues sending e= mail to internals, and though I think I know how to get it through, if it d= oesn't make it, please help :) Thanks!] On Aug 4, 2014, at 12:49 PM, Andrea Faulds wrote: > IMO, it=92d also be good for Hack as it could use this instead of fun(). Yep! I don't think there's a single engineer or user of Hack that doesn't t= hink that Hack's current solution to this is pretty awful :-P (For those un= familiar, see http://docs.hhvm.com/manual/en/book.hackmagic.php, in particu= lar fun/class_meth/inst_meth/meth_caller.) So I love the idea of making a Hack syntax for this that doesn't suck and a= PHP syntax at all. However, I think the current proposal misses an opportu= nity to fix an important issue with "strings as first-class functions" as i= t currently stands in PHP, which is how those strings deal with scope. The = short version is that scope, e.g., for calling private methods, is going to= be checked when you invoke the method via call_user_func/cufa, which is pr= obably not what the programmer would expect -- you usually want a check whe= n you *create* the string/array/whatever that you will eventually pass into= cuf/cufa. It gets a ton more hairy than that -- https://github.com/faceboo= k/hhvm/blob/master/hphp/test/quick/cuf.php is an HHVM test case that is a l= itany of all of the weird ways you can use cuf and how it applies to scope. The RFC goes a long way to fixing this, but one important place it misses i= s with function references to private and protected methods. The crux of th= e issue is that allowing an unbound closure to escape can lead to very unex= pected and unwanted results, as opposed to forcing the closure to be bound = to a particular variable. Consider: