Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114821 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25406 invoked from network); 10 Jun 2021 17:17:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Jun 2021 17:17:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1126C180508 for ; Thu, 10 Jun 2021 10:32:35 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,URIBL_SBL, URIBL_SBL_A autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 10 Jun 2021 10:32:34 -0700 (PDT) Received: by mail-lj1-f178.google.com with SMTP id r16so6094789ljc.0 for ; Thu, 10 Jun 2021 10:32:34 -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=wIQ2GbOWJsVdrTAcACtav4+IXp8D3x9HgE6+id/Fo/k=; b=tw2mXiRLzNRK5+fUQC9gaC0zSI7nH5nJZHfAGoCvsGylOL7VOzgwv1Ornrw5+Ub6Bp QOuE4z0X3rX4kNuG2RGf3pG8HZ1ijixdeG6pYVrmxjUh6Hjb4o2MP4VnVpaCPcGy7+YA qDS8wsLDhq4w81lDLq6DnUfYRiU9uJHw9NU6P5rEn4m7GGIA8popgPLW9W6wR3ob1lK/ ei1vvju1L35WGz9okvaLu3cJMsEIe0yprEKVzgJmF+I+Fx0dfU0xG5WgGGXbPZdfpocU kFeFtdFb5GxlkhgvzenT5mlFYx8ynFlVPTC7QOI5c7fQ3X8R3nnCsoEeokNhXbBpc1YE QTNg== 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=wIQ2GbOWJsVdrTAcACtav4+IXp8D3x9HgE6+id/Fo/k=; b=CvBo3j0TReqCB1AcY0wk3YLL089Sy2ISSBZSsXIHexiYQzZDHBIlc9cMNQEMyQGQRX QCfnUjItpaxxYPwoYrKLOzGvSItIe47P0jtWPkCZUYYbnPozj03hWYEVKUANylvPCqVc iIrI+SlJQK5f7m6BiiQArhIRATx32cWnNnRbedDVMQxeqUvxYCgSdkxkJfGBtaOXSnVj iHN9ogbWw+TFtE8+KF5bNYKN0MCxlFWhlGmn+5wggXM5zXDdr4o6SakZ2qHtFnQa2euP nteKJFOSZ3aidSS+Y/opeYIWQSyFCjE/JbJ122ogXk0xKjRf3pX6OisCqxXoCs1eqh08 UKvg== X-Gm-Message-State: AOAM533H49V+bJ62RBKxUItBGsWJDwm2ZMidEND/zSFzfTLCvudbwTfR w34sufXXzc06dlkS707MGBLEYMajFqiWY+2MZx/CF7jxl+xtYhU= X-Google-Smtp-Source: ABdhPJxh+Nv5gEDiXpsp12NHgP8uKwZnj6YiUkJfvlBfGhqUpdGxnKoBSWWDiQYY5s4re/8Go6T6/EtAjh+xAsiXcmE= X-Received: by 2002:a2e:5c03:: with SMTP id q3mr2955069ljb.233.1623346352558; Thu, 10 Jun 2021 10:32:32 -0700 (PDT) MIME-Version: 1.0 References: <9adf063b-2598-4dd4-9e2b-cf2cd4f53b86@www.fastmail.com> In-Reply-To: Date: Thu, 10 Jun 2021 19:32:21 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000b113ff05c46cc6eb" Subject: Re: [PHP-DEV] [RFC] Partial Function Application, take 2 From: guilliam.xavier@gmail.com (Guilliam Xavier) --000000000000b113ff05c46cc6eb Content-Type: text/plain; charset="UTF-8" On Thu, Jun 10, 2021 at 4:34 PM Larry Garfield wrote: > On Thu, Jun 10, 2021, at 3:17 AM, Guilliam Xavier wrote: > > On Wed, Jun 2, 2021 at 7:47 PM Larry Garfield > > wrote: > > > > > https://wiki.php.net/rfc/partial_function_application > > > > for `$null === null`, is `$c = $null->bar(?);` / `$c = > > $null::baz(?);` an immediate error, or only later when calling > `$c($arg)`? > > That dies with "call to member function on null" when trying to create the > partial: > > https://3v4l.org/E6MgK/rfc#focus=rfc.partials > That makes sense (eager evaluation of non-placeholder "arguments", including the called-on object). > > does it > > support nullsafe calls, e.g. `$foo?->bar(?)`? and if yes, what is the > > signature of the Closure when `$foo === null`? > > I just checked, and it... sort of supports nullsafe. Rather, if you try > to partial a method on a null object, you get null back for your closure. > Then when you try to call it, you get a "cannot invoke null" error. > Which... I think makes sense. > > cf: https://3v4l.org/4XeB3/rfc#focus=rfc.partials Well I find that unexpected :/ > As a cute side effect, Joe pointed out you could do this: > > https://3v4l.org/ERRdY/rfc#focus=rfc.partials So there's a "workaround", although I wouldn't call it precisely "cute"... > I wouldn't really call that a feature, but more of a side effect of the > implementation. Please don't count on that behavior. > I'd rather not indeed ;) Since `$null?->whatever(1, 'a')` currently always returns null without error, shouldn't `$null?->whatever(?, 'a')` return a closure (with a signature built from the placeholders only) that will return null when called (i.e. equivalent to `fn (mixed $arg1) => null` here)? Thanks, -- Guilliam Xavier --000000000000b113ff05c46cc6eb--