Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105264 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63050 invoked from network); 12 Apr 2019 18:43:07 -0000 Received: from unknown (HELO mail-it1-f171.google.com) (209.85.166.171) by pb1.pair.com with SMTP; 12 Apr 2019 18:43:07 -0000 Received: by mail-it1-f171.google.com with SMTP id k64so16241110itb.5 for ; Fri, 12 Apr 2019 08:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/uqwDYk0YcuI4ghFaoDr0r6u+QPxGpQxdMq0bk/w3Fo=; b=DDu5hQ0AesBKNoepLgzQpa7PiV1iA13YtGTR9uQV6AHa/hKodaJc003BgvZ7ymD8Wb 5TImDektQ4cP/rZDYUA0SXIsdYqgz0dCRuaDIpP7y25RjQAmJ4CLEQGbWXy/wLQ6S0Wf PrMCTwEn35rPGRV2Q/SN/+dIGujqpGqOeztiLZZyTgJHgYx12RLwkiBfxNHQ0w30S+Sm bEaWS+6MyulSkrmqgdSqjFskkSiMIllBDuU1xBdLGASc+DhnL51eZsfL9Q2iSNaUfqUZ E8rqYkQB1kTmDWRnK4klN6ipWgOWQntgmjAL58UA2RnUkZ2cZgpA9Cd6+a9dk92/KjIG Q0mA== 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=/uqwDYk0YcuI4ghFaoDr0r6u+QPxGpQxdMq0bk/w3Fo=; b=ARa8f/rbi+ar9KzSrceOorkCvooKIlJ68icCJYkNcWq+fN0VzqnpEdfnqHyBO/FK0t /SkQjpilvZj7ZRdaGLUiJQ8yX8GrpbG3f/TrNT4RtTruiEn2cW8gmS5ZbsX7/YhPkdnX xebfJY9I+KrhCH112RaC3cr9d8IwpnAWG12HNY6oYOwkkUtrHOcn5MYVqObHJ3gR45zV W59pv1n72TFSLAmrgH7d3hJ1r8blyGCwzPKK5vziB5d4YF7jdPHMg6N1kJOoBZfJjLk8 dGO7B9hbY0iWsNsIm9LdKkbZfPvlI2E1wsf8IUV65vkYdDBvP3pOmAyR9bpEZheLoHcZ OOjg== X-Gm-Message-State: APjAAAXSz0oAECuMEdrurzWA5lCzly99LubX3nE7YPmxKxcAJ7kBekA8 HUDLB4/NLDatrpjqHRpTukkrkhGMrDrzDGCtAdY= X-Google-Smtp-Source: APXvYqw6qT/arbUBIeCKl+7cElJaXCRUvfo0HInsiTzwoxWOHgTDWBZnPgLPlyPCsfFibGci+8mNg1EX5kpGB9nBRoo= X-Received: by 2002:a05:660c:38e:: with SMTP id x14mr14461697itj.146.1555083646569; Fri, 12 Apr 2019 08:40:46 -0700 (PDT) MIME-Version: 1.0 References: <582b57dc-42a0-582b-9471-2ede97ba584a@telia.com> <9C232925-ECA1-4DB3-91A5-FE76C3BA1F4A@koalephant.com> <6A90A882-6DD3-48CB-94CA-82059F6949B8@gmail.com> In-Reply-To: Date: Fri, 12 Apr 2019 16:40:34 +0100 Message-ID: To: Fabien S Cc: Theodore Brown , PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Re: [RFC] Arrow functions / short closures From: joshdifabio@gmail.com (Josh Di Fabio) On Fri, Apr 12, 2019 at 4:27 PM Fabien S wrote: > > > > On 12 Apr 2019, at 16:46, Theodore Brown wrote: > > > > On Thursday, April 11, 2019 at 10:22 AM Fabien S wrote: > > > >> I really like the Haskell `\($x)` syntax, could someone confirm if > >> it would possible to drop the parenthesis (like `\$x`) if we have > >> one argument ? > > > > The RFC says this syntax is ambiguous without the parentheses, since > > the `\` may also be part of a fully qualified type name. [1] > > > > I'm not sure whether it would work if the single parameter isn't typed. > > > > I like the Haskell syntax as well, but I'd also be okay with the `fn` > > keyword if that's what others prefer. > > > > [1]: https://wiki.php.net/rfc/arrow_functions_v2#miscellaneous > > > Thanks for the clarification, I should have been more specific but I saw you used `\$x` in your previous message and I was wondering if this syntax is unambiguous. > > Basically: > > ```php > \$x => $x + 1; // One (not typed) argument, no parenthesis needed > \(int $x) => $x + 1; // Typed, parenthesis needed > \($x, $y) => $x + $y; // Multiple arguments, parenthesis needed > ``` > > I don't think it's really important but it would be pretty handy syntax in my humble opinion. Agreed. Arrow functions work the same way in TypeScript I think (parens are required for typed parameters). > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >