Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Levi Morrison via internals
On Thu, Apr 20, 2023 at 9:57 PM Deleu wrote: > > > > On Thu, Apr 20, 2023 at 8:23 PM Levi Morrison via internals > wrote: >> >> I'm going to stop here. Two big things: >> >> 1. I think reducing verbosity can be left for the future. We don't >> have to solve that right now. > > > >> What

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Deleu
On Thu, Apr 20, 2023 at 8:23 PM Levi Morrison via internals < internals@lists.php.net> wrote: > I'm going to stop here. Two big things: > > 1. I think reducing verbosity can be left for the future. We don't > have to solve that right now. > What happens if I pass a short-closure? > >

[PHP-DEV] Expansion of PHP Symbols?

2023-04-20 Thread Deleu
Hi Internals, sorry for the potential long email, but I can't sleep and I want to dump this out of my brain. Just a quick intro, let's recap PHP simple nature with this index.php file: ``` https://wiki.php.net/rfc/core-autoloading) and Callable Interfaces ( https://externals.io/message/120083)

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Levi Morrison via internals
On Thu, Apr 20, 2023 at 11:25 AM Larry Garfield wrote: > > Hi folks. This is a pre-discussion, in a sense, before a formal RFC. > Nicolas Grekas and I have been kicking around some ideas for how to address > the desire for typed callables, and have several overlapping concepts to > consider.

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 9:47 PM, David Gebler wrote: > On Thu, Apr 20, 2023 at 6:25 PM Larry Garfield > wrote: > >> ## The options >> >> There's three ways we've come up with that this design could be >> implemented. In concept they're not mutually exclusive, so we could do >> one, two, or

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread David Gebler
On Thu, Apr 20, 2023 at 6:25 PM Larry Garfield wrote: > ## The options > > There's three ways we've come up with that this design could be > implemented. In concept they're not mutually exclusive, so we could do > one, two, or three of these. Figuring out which approach would get the > most

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 8:26 PM, Michał Marcin Brzuchalski wrote: > Hi > >> There is one loophole, in that an interface may require an __invoke() >> method: >> >> interface TwoInts >> { >> public function __invoke(int $a, int $b): int; >> } >> >> > I was playing around with the code and

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Michał Marcin Brzuchalski
Hi > There is one loophole, in that an interface may require an __invoke() > method: > > interface TwoInts > { > public function __invoke(int $a, int $b): int; > } > > I was playing around with the code and parser for this in 2020 but my idea was to introduce a new syntax that is inspired by

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 7:30 PM, Dan Ackroyd wrote: > On Thu, 20 Apr 2023 at 18:25, Larry Garfield wrote: >> >> Hi folks. This is a pre-discussion, in a sense, before a formal RFC. > > > Hi Larry, > > The "Allow casting closures into single-method interface > implementations" one seems a

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Michał Marcin Brzuchalski
Hi Tim, czw., 20 kwi 2023 o 16:39 Tim Düsterhus napisał(a): > ... > But please no entirely new syntax with braces as it currently is shown > in the examples in the RFC. > Then we should vote for syntax. Personally, I prefer braces here because it doesn't look like a regular function call

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 7:10 PM, Deleu wrote: > On Thu, Apr 20, 2023 at 2:25 PM Larry Garfield > wrote: > >> But that runs quickly into the problem of verbosity, reusability, and type >> aliases, and the discussion usually dies there. >> > > Just out of curiosity, was there ever a discussion

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Dan Ackroyd
On Thu, 20 Apr 2023 at 18:25, Larry Garfield wrote: > > Hi folks. This is a pre-discussion, in a sense, before a formal RFC. Hi Larry, The "Allow casting closures into single-method interface implementations" one seems a complete non-starter, as that seems really hard to work with. You'd have

Re: [PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Deleu
On Thu, Apr 20, 2023 at 2:25 PM Larry Garfield wrote: > But that runs quickly into the problem of verbosity, reusability, and type > aliases, and the discussion usually dies there. > Just out of curiosity, was there ever a discussion thread dedicated for Type aliases? I couldn't find it on

[PHP-DEV] [Discussion] Callable types via Interfaces

2023-04-20 Thread Larry Garfield
Hi folks. This is a pre-discussion, in a sense, before a formal RFC. Nicolas Grekas and I have been kicking around some ideas for how to address the desire for typed callables, and have several overlapping concepts to consider. Before going down the rabbit hole on any of them we want to

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Aleksander Machniak
On 20.04.2023 16:15, Larry Garfield wrote: or $point = clone($point, x: $x, y: $y, z: $z); Also, I didn't see it mentioned, but maybe for future scope, these new arguments should be passed to __clone(). They should not. See

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Tim Düsterhus
Hi On 4/20/23 16:17, Larry Garfield wrote: On Thu, Apr 20, 2023, at 7:00 AM, Rowan Tommins wrote: Rather than making everything use an array or array-like syntax, I would probably go the other way and scrap the special syntax for dynamic names, making the whole thing look like a function

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 7:00 AM, Rowan Tommins wrote: > Rather than making everything use an array or array-like syntax, I > would probably go the other way and scrap the special syntax for > dynamic names, making the whole thing look like a function call, with > support for array unpacking:

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Larry Garfield
On Thu, Apr 20, 2023, at 7:22 AM, Aleksander Machniak wrote: > On 20.04.2023 09:00, Rowan Tommins wrote: >> Rather than making everything use an array or array-like syntax, I would >> probably go the other way and scrap the special syntax for dynamic names, >> making the whole thing look like a

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Rowan Tommins
On 20/04/2023 08:11, Robert Landers wrote: public function withStatus($code, $reasonPhrase = ''): Response { return clone $this { $this->statusCode = $code; $this->reasonPhrase = "Old: $this->reasonPhrase, New: $reasonPhrase"; } }; Note that this is not the

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Aleksander Machniak
On 20.04.2023 09:00, Rowan Tommins wrote: Rather than making everything use an array or array-like syntax, I would probably go the other way and scrap the special syntax for dynamic names, making the whole thing look like a function call, with support for array unpacking: $point = clone

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Robert Landers
On Thu, Apr 20, 2023 at 9:01 AM Rowan Tommins wrote: > > On 18 April 2023 17:48:00 BST, "Tim Düsterhus" wrote: > >I'd rather see only the fat-arrow being allowed. Unless I'm missing > >something, braces with colon is not used anywhere else, whereas braces + > >'=>' is known from match() and

Re: [PHP-DEV] [RFC] [Discussion] Clone with

2023-04-20 Thread Rowan Tommins
On 18 April 2023 17:48:00 BST, "Tim Düsterhus" wrote: >I'd rather see only the fat-arrow being allowed. Unless I'm missing something, >braces with colon is not used anywhere else, whereas braces + '=>' is known >from match() and '=>' more generally is already used with array literals [1].