Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93455 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4175 invoked from network); 23 May 2016 19:52:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 May 2016 19:52:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.48 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.220.48 mail-pa0-f48.google.com Received: from [209.85.220.48] ([209.85.220.48:33016] helo=mail-pa0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 23/2C-14293-57F53475 for ; Mon, 23 May 2016 15:52:21 -0400 Received: by mail-pa0-f48.google.com with SMTP id xk12so65297995pac.0 for ; Mon, 23 May 2016 12:52:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-transfer-encoding; bh=geaSjmMvRyh5YPCEC8EC5M5NYR9kNS/avMkM7fITjpE=; b=RsUr5Dtl9PjunSBJeElCQO1wa0PINqoAJJ6t0wnY1lLxcRl54p8UhUsFTlxGsPlTKW o+0xUMKco+TkozyvUcGxn4IV8ORalO2sKv/vX1ZMdIKNFUCexw2il03Hjbx22G+EuNMl 9FCpUC7E0hj1wrqnrpAerHDiiJ3SjK5gsJvtzzknDizYhz2xAVNzDr8ZNcBvrKJQn5WH KMKX857Lk+XJDBPN1REPNiIops6NU75TY446a7QN3EMgYFQ80MjXtfCHCpGx3ZaMIIab 9MOCeKccflrTLB/Adl3BXrS+h6zoLzKDy/951boC/RDfAc72UOznVX8xYgt2cCYm1EvR qv9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=geaSjmMvRyh5YPCEC8EC5M5NYR9kNS/avMkM7fITjpE=; b=QHUqfHek/grK/XbbD1mP50QW4oxInojuWCUj382cHy+9tju11bSNEfrgvF+OuIDFZr VMvUJhNk4SjD7X/em2miCgmMdOTIKQ0FOHSy50Rc6LCowmD1ZSDVVUo3bSN7ESoolIwY ZvA4zbHChWFI93ULrGEKw4ZuAO3gBs+HPX4nTB6ba0bm1Sthq+fjHCOAekiXgglPmXHM cqBS/cpx5bVIuoCHg5vN+xzQcKZWrQtyxS+vLeirlWWa280n41zkbSCyTyYfaPNe2xfD Cf3LN4w96HlycOqiEdix5OjaGp2hJBkFhwPEOj8OUQTEp0Dk51pUiMTWUFsGy8CPEyqA GfLw== X-Gm-Message-State: ALyK8tJCGbK2ryEhMVpbDuiHvNiZSbpehjdaa0zB9iR07RGT1FUsyQEDbHuPB27enUAc5WMHLTLdezDBz+MG5w== MIME-Version: 1.0 X-Received: by 10.66.217.137 with SMTP id oy9mr816079pac.103.1464033138505; Mon, 23 May 2016 12:52:18 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.66.132.79 with HTTP; Mon, 23 May 2016 12:52:18 -0700 (PDT) In-Reply-To: <5388A629-AA48-4CB8-8106-90BAA9B9F227@gmail.com> References: <5388A629-AA48-4CB8-8106-90BAA9B9F227@gmail.com> Date: Mon, 23 May 2016 13:52:18 -0600 X-Google-Sender-Auth: iEiBi22eQhfrTz8pjjoY5m59New Message-ID: To: Nikita Nefedov Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] [Vote] Callable types (now: Callable prototypes) From: levim@php.net (Levi Morrison) On Mon, May 23, 2016 at 1:19 PM, Nikita Nefedov wrote: > >> On 23 May 2016, at 19:31, Levi Morrison wrote: >> >>> On Mon, May 23, 2016 at 8:27 AM, Nikita Nefedov wr= ote: >>> Evening internals, >>> >>> With this message I'd like to go to vote >>> with the Callable prototypes RFC targeted at 7.1: >>> https://wiki.php.net/rfc/callable-types >>> >>> We've renamed it (previously was "Callable types") as RFC names often >>> dictate how users will call the feature and I want it to be more >>> accurate/descriptive. >>> >>> Also the reflection part was added although I'm short on time currently= , >>> so implementation for that will be ready later. (speaking of implementa= tion, >>> it also currently doesn't use cache_slots - also something I'll add whe= n >>> I have a little bit of time) >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >> >> A quick question before I vote: do callable prototypes allow for >> default parameters in the signature? There are examples for having a >> function passed that has a default parameters but I am not seeing it >> anywhere in the callable prototype definition so I thought I'd ask. > > Hey Levi, > > Although it could be done as a later RFC, my stance on it is that default= values don't belong to the prototype of the function. > > Why I think that callable typehint doesn't need default values for params= is: you either need this parameter to exist and even if there are cases wh= ere you'd like to pass some kind of 'default' value implicitly, you as a ca= ller shouldn't impose on the callee responsibility to have this same value = in his definition and instead just pass your argument explicitly... or if y= ou don't need this parameter (as in you don't plan to pass anything explici= tly) then you should just ask for a function without this parameter as ther= e is clearly no need for it at all. > > Moreover I would argue interfaces have it wrong here too: the fact that d= efault values are part of an interface yet their invariance is not enforced= , yields an interesting sort of possible LSP violation. F.e. if we have an = interface Logger (a completely unreal example but it shows what can go wron= g) with function 'log($message, $level =3D LOG_DEBUG);' and a funny impleme= ntation that decided to change default value of $level to LOG_ALERT, then a= ll callers of Logger#log who relied on the fact that level if not specified= , will be LOG_DEBUG, who also happen to get the funny implementation of Log= ger will produce unneeded noise in the logs with their alert level messages= which were intended to be debug messages :( Please document this restriction in the RFC. I guess I'm the only one who expected it to be there since it didn't come up before, but it just seems missing. You don't need to take it out of voting for this clarification, imo.