Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92665 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35789 invoked from network); 23 Apr 2016 18:34:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Apr 2016 18:34:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcio.web2@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcio.web2@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.45 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.218.45 mail-oi0-f45.google.com Received: from [209.85.218.45] ([209.85.218.45:33625] helo=mail-oi0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CE/84-07837-540CB175 for ; Sat, 23 Apr 2016 14:34:46 -0400 Received: by mail-oi0-f45.google.com with SMTP id r78so144696217oie.0 for ; Sat, 23 Apr 2016 11:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=zoh80VLBfd4PEdxC3piH++S0QjwecoK5d5TmRwIsyoc=; b=T4B4CvUfT6L0uhGPj49ky4kJcuhwMF+l6yktyKVAaS5kCQLCQ+/NoQa8yL5nSJAjrT SuE59UtkCzZk6ZZFecB3prHoXUiMVhQjWiFh9UIYkL85ggw//LI3skc0LBoHIlaj1BKR D7xgdVFUTx6GhTNVE7hkW3Vpc7V/7yBO/CF+Yml9USCE9IHcBMW3uPu28bGjBU6TaErE uZNIJW/vTnL34O+R41/MNWv4ApF8eA/3UuaxT1SbF3DDtzasxGI3DLSHBr0u5dsBa5bB LsRC1+qBnYa5XTYrF6up812O/uZ4N8loqfn4k9fcaBQbruP10InlJHjQqswH3Kln13Vj gYVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=zoh80VLBfd4PEdxC3piH++S0QjwecoK5d5TmRwIsyoc=; b=KHxzf+uydWIwgFTAHb320PrkXURYJ/Id/GkV7Fxi6pWEswgECmDlCnb1xaHCAg3FiX wU/RzADUoP6rkdagBIPnMTRkvsPnWMa27Zh51M50spyVWw5Qumnrjj0dax3WG4BdYiCc X2jPzi5V4zPRoquEre26hIFABU/8cLCJpZfByp6os0+HkiT1vwc29VW/gHt4RkStsWco xFMb1/mNKVIaXeWfTclIxXP9qIqCWlcNYJwj3+9M7JKmsiUUB2z4aTzjP0eLGNw5tNDH qg/S70VsAjHpBYK4kU2TCMRiKsZBFChJD9ERvVzCc+HzlB3W9+rmpvt+7Em5NUYafogA 0Odw== X-Gm-Message-State: AOPr4FW8Aov07xmj0nfgYGCw66JzcmOzNZifzW54iLAI0DuQOy9bs9ccU3/TD8+CGevCh3670X0lz3dYIwwFuw== X-Received: by 10.202.78.10 with SMTP id c10mr6904652oib.134.1461436482857; Sat, 23 Apr 2016 11:34:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.192.198 with HTTP; Sat, 23 Apr 2016 11:34:23 -0700 (PDT) In-Reply-To: References: Date: Sat, 23 Apr 2016 14:34:23 -0400 Message-ID: To: PHP internals , Mathieu Rochette Content-Type: multipart/alternative; boundary=001a11c172da6c32a605312b323a Subject: Re: [PHP-DEV][RFC] Callable Types From: marcio.web2@gmail.com (Marcio Almada) --001a11c172da6c32a605312b323a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable hi! From: Mathieu Rochette > Date: 2016-04-23 12:44 GMT-04:00 > Subject: Re: [PHP-DEV][RFC] Callable Types > > > On 04/22/2016 06:12 AM, Marcio Almada wrote: > > Hello everyone, > > We just completed the draft for the "Callable Types" RFC. This RFC has be= en > recently mentioned during other type related threads on this mailing list= , > so it feels to be the right time to put the proposal in context: > > The proposal is at https://wiki.php.net/rfc/callable-types > > It looks very nice overall :) and would be, imho, a great addition to PHP > > > I have a few comments, first about the optional arguments, the example in > the rfc says : > > // That means that foo() could call $cb and pass anything as a first > argument and if it would be something that is not an instance of A the ca= ll > would fail. > I don't get why foo would be declared as > > function foo(callable() $cb) { } > > instead of > > function foo(callable($any) $cb) { } > > if foo intends to call $cb with an argument. > > > what about optional arguments, eg: > > class Foo > { > private $logger; > public __construct(Logger $logger =3D null) {$this->logger =3D $logger;= } > public doSomething(callable(int $done, int $remaining, Logger =3D null) > $progressCb) { > // ... > for($i =3D 0; $i < $n; $i++) { > // ... > $progressCb($i, $n - $i, $this->logger); > } > } > } > > should that be supported ? > > Currently you can nullify or skip the Logger argument upon implementation of the callable. Rendering your example: https://3v4l.org/qb5QR/rfc#tabs Admittedly, the expectation for default values to work seems legit and we are currently discussing whether to support default values on callable types signatures or not (inclined to do not support). But honestly I haven't seen a legit use case when we already have the ability to satisfy the callback with a smaller type. Perhaps you may have one use case where a default value would be indispensable? > > and last one, will instanceof supports this new syntax? > > Yes, please expect to see this on the next minor version of the RFC :) > > thank you > > The W.I.P patch is available for testing through http://3v4l.org under th= e > RFC tab. > > We count with your detailed feedback and insights. Let's have a nice, > respectful and > constructive conversation about the RFC and work on possible improvements= ! > > Thanks > Nikita Nefedov > M=C3=A1rcio Almada > > > -- > Mathieu Rochette > > Cheers. --001a11c172da6c32a605312b323a--