Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103393 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54405 invoked from network); 26 Oct 2018 19:47:27 -0000 Received: from unknown (HELO mail-lf1-f43.google.com) (209.85.167.43) by pb1.pair.com with SMTP; 26 Oct 2018 19:47:27 -0000 Received: by mail-lf1-f43.google.com with SMTP id q6-v6so1294530lfh.9 for ; Fri, 26 Oct 2018 09:03:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ncnh0jPjHhx6hSqC4dzXSDogObo6Z3CIiTkLvpdFuJs=; b=d0ADQ0RO3NLzsVZDZW3JdFi/zhr7FFpUFNjUdn/w5+z4uv9Yuyy6POVooOcc7FJpVL eV86G9K0gBR0EP+LQMZ516voDnhE9kGfbDMww9fz43HURUp0Nm2bjSdCf1m+5lmoBr9j qMpwkrpfhqG4yEj6GOILrBQBM9lMx+Oe7e8ozGJwvwbn2di47Fl0/9ELmYGsnKUXxpzt Zo9YnFLLo53zD13eaox5TamBoA2bjvMNTEC/fy7Ao0aiPq+okeJ+5vMubsYqOFRdCbsM F6OylxR5REHm8fVHx8B66tI4HrKSAVA+RZIm1vvX/rqaV/gCWwhE3PUxVlfkTRinV3T4 8RBg== X-Gm-Message-State: AGRZ1gIypwEavSigKNtQQhu/awXoJDuj3J0T8Hsi+iU3VGGuIYPHXDTB yR++YUfOTZb1IKVv0jJdSDWraMO4p5TWgAgzG8fE7w== X-Google-Smtp-Source: AJdET5cHdwoeGyFgNC23xOfegKYCmE7i3I0wEzx7vpz4fhbG/BYExN26X2BVos84tNVH3mSTUvdJYTQjBfkViPxor4k= X-Received: by 2002:a19:7112:: with SMTP id m18-v6mr2579189lfc.64.1540569786363; Fri, 26 Oct 2018 09:03:06 -0700 (PDT) MIME-Version: 1.0 References: <2370262.6EcsR2toYx@vulcan> In-Reply-To: Date: Fri, 26 Oct 2018 10:02:49 -0600 Message-ID: To: Kalle Sommer Nielsen Cc: Larry Garfield , internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Idea for better function callbacks (another syntactic sugar) From: levim@php.net (Levi Morrison) On Fri, Oct 26, 2018 at 9:57 AM Kalle Sommer Nielsen wrote: > > Den fre. 26. okt. 2018 kl. 17.43 skrev Larry Garfield : > > I believe the proposal for short lambas (which should get resurrected at some > > point) would handle this case well enough as well as help a dozen other > > things. To wit: > > > > array_filter($names, |$x| ==> trim($x)) > > I still fail to see why it would be considered to have that over a > perfectly encapsulted string for a callback, using a lambda/closure is > just an extra runtime call for syntax sugar, that seems poor in my > eyes. > > What would be ideal here, would be for functions to be first class > citizens in callback contexts, like in C to avoid the quotation, > however it clashes with constants. A hack you can do in userland could > be something like: > > const trim = 'trim'; > array_filter($names, trim); In my opinion "ideal" here is that our symbol tables are merged, so referring to "trim" in any context will resolve to at most one symbol, *and* that we also have a short-closure syntax for times when there isn't a *perfect* function to use. In the next version of PHP I would really like to see some warnings for when symbol names get re-used so that in the future we can merge them with less of a BC break.