---- En vie, 08 may 2020 15:07:13 +0200 Dan Ackroyd <dan...@basereality.com> 
escribió ----
 > On Fri, 8 May 2020 at 07:49, Manuel Canga <p...@manuelcanga.dev> wrote:
 > >
 > > What is your opinion ? Do you see it useful ?
 > 
 > I can see the need; I strongly dislike the idea of using references for this.
 > 
 > What you're describing is a form of 'out parameters' which have been
 > mentioned a few times before on this list.
 > 
 > I've made a note of the general idea here:
 > https://github.com/Danack/RfcCodex/blob/master/out_parameters.md
 > 
 > Though the wikipedia article is also good:
 > https://en.wikipedia.org/wiki/Parameter_(computer_programming)#Output_parameters
 > 
 > Using references for things like this is a bad idea as references make
 > it hard to reason about code. In this specific case, having the
 > function mutate the existing variable is horrible.

Hi, Dan, 

I think nothing is bad practice. It depends of context. 
Example: global variables, __set/__get, public properties and so on could be 
considered bad practices,
however, they sometimes are useful.

References could be a priori bad idea, but if you limit your their 
dangerousness, they will be less bad.

 > 
 > > If nobody objects to this RFC
 > 
 > While you categorically must do what you must, I don't think you will
 > get much benefit  from raising this as an RFC until you find someone
 > who can and is willing to implement it.

I agree :'(

 > 
 > Actually, just finding any core contributor who is willing to say that
 > they would back this idea might be a good idea.
 > 
 > And yes, phpinternals could still really do with an 'informal but only
 > to open to voters' feedback mechanism. Someone should do something
 > about that....wait I'm _someone_. And I have wiki permissions.
 > 
 > So here's a page for a non-binding 'indication of interest' poll:
 > https://wiki.php.net/indication_of_interest/keep_type_of_reference_params

Thanks so much, Dan

 > 
 > If anyone disagrees with the text, either please suggest a change or
 > edit it if you have karma.
 

I'd add( but I don't have karma ):

Add a new`inout` keyword( very similar to 'inout' of Hack ) in order to:

- Check type of out is equal to type of param( like example of my first email 
). 
- Avoid modifying caller variable value when the function throws an exception. 
( Thanks to Mathew for link to inout* of Hacker language )
- Allow explicit call-site pass-by-reference annotation. ( Thanks to Rowands 
for link** to Nikita's RFC )
 

* https://docs.hhvm.com/hack/functions/inout-parameters
** https://wiki.php.net/rfc/explicit_send_by_ref

 > cheers
 > Dan
 > Ack

Thanks again, Dan,

Regards
--
Manuel Canga

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to