Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105108 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 18710 invoked from network); 5 Apr 2019 15:20:05 -0000 Received: from unknown (HELO mail-it1-f174.google.com) (209.85.166.174) by pb1.pair.com with SMTP; 5 Apr 2019 15:20:05 -0000 Received: by mail-it1-f174.google.com with SMTP id y204so9038373itf.3 for ; Fri, 05 Apr 2019 05:15:58 -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=BbDzLTblQx9fq+k6f+GPH04VoBKu2Y5oCddWyzjKgnA=; b=hnStUBjIdYQDIvyYzCFgNDbDVQUZrHQvPl+1G6VTCX3thgmTLp87KGhHdLk5alyuoK G1adsgcGwhV5MhlMdTj7v5nfWxWKJ1q+avuBJexAOv8Za8f31Q5nKD6pSF7MWI7oRFXu EsHH0OacbtmdKrw3rMIZdkNQaTwiwLykXTMylsuYfh9FiO5qFvbszucr7VgsoQBp/eyr ye8ubeBxwy5HKEHJ5zfkSO5PnQLNx6wT4HnFMSbUD5jVn3iqffqq+c1YwDsNcva5jKV9 gS+teROP+NLAthkashMo5M667v0oTYLfg5zlfClAC1B/luOtFkVNgsfFwJML7SHekX8k yC4A== 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=BbDzLTblQx9fq+k6f+GPH04VoBKu2Y5oCddWyzjKgnA=; b=ivLYnrhFSADGlUmcAVqAcIKGs/uEM6791xpW7t/LyqzUkpCplz62QH9hgS+weurJlU DmUNCNkVhOU1VvIlFxC3Qd7aFeE5ClHqgaduLgfkIVxOXI+jYI7N79eGfDh0f3fz6YZE BCvln0/eu+RnZDmNs0W4lttVuswAlTtL4hQnlgUIEfsXkJ+9mhfwxHP/URxXDO3b9Gtu n00NZNfTZeF82zPH/etCo5iSibC8SLyBD/dcaspKOO1hT4WtHMvt8GtyYfvVajlGaXMr WTJkx1zCs3frMg+jZ4dy6qCeDOOF/Of65OCNLidpkDTOTfS9UKqyR/RHfEBfqAR7Ok08 Dxcw== X-Gm-Message-State: APjAAAVlcw1zRqTQbevULRP25AQNZCpnMJPzTO06+L06MMNlmdb9hu4n Gviy3ubnctm3yfTAS9cTAmqZkPvRfHjXOO9Yhgo= X-Google-Smtp-Source: APXvYqz/3tcbZ48c0ivcrCyaNgyY3CsEucVo4pWEgnJXZzgDKdWMJ9IPunP2Qtzv6AEnLEh/qgy2XraiflJyzLFl6+g= X-Received: by 2002:a24:3a13:: with SMTP id m19mr8688836itm.88.1554466557853; Fri, 05 Apr 2019 05:15:57 -0700 (PDT) MIME-Version: 1.0 References: <65AF9E1E-DFA6-47AE-952B-9ABEBD9B6038@gmail.com> <284d1f9f-03d3-1488-77dd-82e18edf9f4c@gmail.com> <3144F5D1-1F18-4C42-9B3E-AF1B1E598E47@koalephant.com> <917cb7bc-4abc-4bae-1a5a-b2ba1777fa55@gmail.com> In-Reply-To: Date: Fri, 5 Apr 2019 13:15:46 +0100 Message-ID: To: Robert Hickman Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ff03720585c772b2" Subject: Re: [PHP-DEV] Question about adding !function_identifier From: rowan.collins@gmail.com (Rowan Collins) --000000000000ff03720585c772b2 Content-Type: text/plain; charset="UTF-8" On Fri, 5 Apr 2019 at 12:42, Robert Hickman wrote: > In the first case: > > function foo(callable $bar): int { return $bar(); } > > I think the value of $bar would have to fall into a set of values > known to the programmer, or at least known at some level. I think you're misunderstanding the problem: it's not that the *programmer* doesn't know the types, it's that the *analysis tool* doesn't know them, because the programmer hasn't told it, and currently has no way to tell it. To be confident the code was type safe, it would have to look like this: function foo(callable): int { return $bar(); } ...and every call to it would have to be analysable back to a function explicitly declared as returning int. The same applies to exception checking: you'd need syntax for "accept any callable that never throws", or "any callable that only throws descendants of FooException or BarException". Then you end up with this kind of fun: function curryish(callable<(int, float): int throws FooException|BarException> $callback): callable<(float): int throws FooException|BarException> { return fn($x) => $callback(42, $x); } Regards, -- Rowan Collins [IMSoP] --000000000000ff03720585c772b2--