Re: [PHP-DEV] [RFC]

This is only part of a thread. view whole thread
  108595
February 15, 2020 12:07 php@manuelcanga.dev (Manuel Canga)
---- En sáb, 15 feb 2020 09:22:41 +0100 Larry Garfield <larry@garfieldtech.com> escribió ----
 > On Fri, Feb 14, 2020, at 1:04 AM, Manuel Canga wrote:
 > 
 > > Maybe, bettern fn:  * fn(callable $to_clsoure ): *closure ?
 > > 
 > > I know fn is used in arrow functions. However, for that same reason fn is
 > > the most convenient.
 > > 
 > > Using dik examples( by the way, they are brilliant ):
 > 
 > Point of order: The Stats analyzer examples were from me, not Dik. :-)  They're taken from one of the monad chapters in the book I'm working on.
 > 
 > --Larry Garfield
 > 

By the way...the following is for folks in internals:

Do you think it is worth creating an RFC page about :: function ? I say that because I see that there are many voices against of :: function
  108601
February 15, 2020 17:01 larry@garfieldtech.com ("Larry Garfield")
On Sat, Feb 15, 2020, at 6:07 AM, Manuel Canga wrote:
> > ---- En sáb, 15 feb 2020 09:22:41 +0100 Larry Garfield > <larry@garfieldtech.com> escribió ---- > > On Fri, Feb 14, 2020, at 1:04 AM, Manuel Canga wrote: > > > > > Maybe, bettern fn: * fn(callable $to_clsoure ): *closure ? > > > > > > I know fn is used in arrow functions. However, for that same > reason fn is > > > the most convenient. > > > > > > Using dik examples( by the way, they are brilliant ): > > > > Point of order: The Stats analyzer examples were from me, not Dik. > :-) They're taken from one of the monad chapters in the book I'm > working on. > > > > --Larry Garfield > > > > By the way...the following is for folks in internals: > > Do you think it is worth creating an RFC page about :: function ? I say > that because I see that there are many voices against of :: function
There seems to be little pushback on the idea of a better way to name/reference functions, so an RFC page for that seems reasonable. What the syntax is, that's still in heavy bikeshed territory, so maybe don't name the RFC based on the implementation detail yet. :-) I'd love to get some input from Nikita or Dimitry or someone else with way more parser experience on how feasible any of the options discussed so far would be; if some are vastly more straightforward than others, that carries a lot of weight. --Larry Garfield
  108611
February 15, 2020 23:25 d.h.j.takken@freedom.nl (Dik Takken)
On 15-02-2020 13:07, Manuel Canga wrote:
> Do you think it is worth creating an RFC page about :: function ? I say that because I see that there are many voices against of :: function
Let us go back to the start of this thread. Your idea was to simplify array_map('\My\I18N\i18n_translate', $array) to array_map(i18n_translate::func, $array) Then the discussion took the topic one level deeper. In your examples, you seek a better way to pass a function as callable. In PHP a callable can be: 1. a string 2. an array 3. a closure Then it was suggested that a short syntax to wrap the function into a closure is more useful. Using strings to refer to functions has consistency issues and the proposed ::func does not solve them. Also, the array syntax for referring to methods could use a better alternative. All things considered, I think the originally proposed feature, using ::func to get the function name, has limited use. Having a ::func (or ::function or ::fn) return a closure might be somewhat controversial and there is no consensus about the name. The only way to know how this will be received is to write an RFC and call for a vote. My own guess would be that an 'enclosure' construct along the lines of array_map({i18n_translate}, $array) array_map({$object->method}, $array) has better chances of succeeding but you never know what happens. Perhaps you could team up with Michał and use the feedback from this thread to produce an RFC. Regards, Dik Takken