Re: [RFC] Callable Types
| From: | Nikita Nefedov | Date: | Fri, 22 Apr 2016 15:18:49 +0000 |
| Subject: | Re: [RFC] Callable Types | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-92647@lists.php.net to get a copy of this message | ||
On Fri, 22 Apr 2016 07:12:13 +0300, Marcio Almada <marcio.web2@gmail.com> wrote:
Hello everyone, We just completed the draft for the "Callable Types" RFC. This RFC has been 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 The W.I.P patch is available for testing through http://3v4l.org under the 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árcio AlmadaHello internals, We're still having a hard time finding a proper format for error message about incompatible callable being passed. Right now it looks like this:
Uncaught TypeError: Argument 3 passed to reduce() must be callable of compliant signature: callable(integer, integer): integer, callable($a, $b, $c) given, called in ...Although it goes in the fashion with all other TypeErrors but it's obviously very cryptic and it will be hard to read for human. One of the alternatives Marcio proposed was:
Uncaught TypeError: Argument 3 passed to reduce() must be compliant with callable(integer, integer): integer, incompatible callable($a, $b, $c) received, called in ...This is remarkably more readable but if you have any suggestions you're welcome. Actually I think other type errors are not very readable as well, take f.e.:
Argument 1 passed to foo() must be an instance of string, boolean givenThe fact that
string and boolean are separated by only one comma,
and the way boolean given is worded (verb after noun) makes it harder
to read. So maybe we could reconsider type error messages and change them
to something more user-friendly, if there's support for this idea...