Re: [PHP-DEV] Final variables

2017-06-29 Thread Marco Pivetta
Hey Dan, On Thu, Jun 29, 2017 at 12:07 PM, Dan Ackroyd wrote: > On 29 June 2017 at 05:20, Marco Pivetta wrote: > > > References to properties ...is effectively a BC break for anything > > using reflection and closure scope binding > > No it's not. > > If that feature was brought into PHP, any c

Re: [PHP-DEV] Final variables

2017-06-29 Thread Marco Pivetta
Hi David, On Thu, Jun 29, 2017 at 11:58 AM, David Rodrigues wrote: > > The `final` modifier would likely clash with property type definitions, > if those ever make it to the language. > > Still, a few pain-points remain: > > * References to properties (you cannot reference final properties > an

Re: [PHP-DEV] Final variables

2017-06-29 Thread Dan Ackroyd
On 29 June 2017 at 05:20, Marco Pivetta wrote: > References to properties ...is effectively a BC break for anything > using reflection and closure scope binding No it's not. If that feature was brought into PHP, any code that is currently valid, that the library is capable of reflecting, would

Re: [PHP-DEV] Final variables

2017-06-29 Thread David Rodrigues
I will try answer the questions: > I get that, but I still don't understand why you would forcefully need > it to be a variable still then if you know the value is gonna be > constant, of course besides global visibility or in iterations "final" is not "const". "final" mean a initial state that w

Re: [PHP-DEV] Final variables

2017-06-29 Thread li...@rhsoft.net
Am 29.06.2017 um 11:25 schrieb Marco Pivetta: On Thu, Jun 29, 2017 at 11:19 AM, li...@rhsoft.net mailto:li...@rhsoft.net>> wrote: in other languages like Visual Basic constants are fast, in PHP they are slow, both in define and access Two things here: 1

Re: [PHP-DEV] Final variables

2017-06-29 Thread Marco Pivetta
On Thu, Jun 29, 2017 at 11:19 AM, li...@rhsoft.net wrote: > in other languages like Visual Basic constants are fast, in PHP they are > slow, both in define and access > Two things here: 1. don't ever consider visual basic for any comparison of any sort: it's basically (ha!) the worst example o

Re: [PHP-DEV] Final variables

2017-06-29 Thread li...@rhsoft.net
Am 29.06.2017 um 11:08 schrieb Marco Pivetta: Final is about having immutable data. Immutable doesn't mean that it's a system wide constant, it means that it's referentially pure in its scope. i refered to "why you would forcefully need it to be a variable still then if you know the value is

Re: [PHP-DEV] Final variables

2017-06-29 Thread Marco Pivetta
Final is about having immutable data. Immutable doesn't mean that it's a system wide constant, it means that it's referentially pure in its scope. On 29 Jun 2017 11:05 AM, "li...@rhsoft.net" wrote: > > > Am 29.06.2017 um 04:50 schrieb Kalle Sommer Nielsen: > >> 2017-06-28 20:46 GMT+02:00 David R

Re: [PHP-DEV] Final variables

2017-06-29 Thread li...@rhsoft.net
Am 29.06.2017 um 04:50 schrieb Kalle Sommer Nielsen: 2017-06-28 20:46 GMT+02:00 David Rodrigues : The "final" keyworks make a "local scope" variable value "blocked to rewrite" after instantiate it. Okay, it sounds like a "const", and it is, but "not as we known it". I get that, but I still d

Re: [PHP-DEV] Final variables

2017-06-28 Thread Marco Pivetta
The `final` modifier would likely clash with property type definitions, if those ever make it to the language. Still, a few pain-points remain: * References to properties (you cannot reference final properties anymore, and that is effectively a BC break for anything using reflection and closure

Re: [PHP-DEV] Final variables

2017-06-28 Thread Kalle Sommer Nielsen
2017-06-29 1:07 GMT+02:00 David Rodrigues : > readonly $number = mt_rand(); > I agree that "readonly" is a better keyword, but we have to points here: > 1. "final" is used on some language (Java, C++ I guess); > 2. "final" keyword does exists on PHP with a "similar" behaviour; > If we can implem

Re: [PHP-DEV] Final variables

2017-06-28 Thread Kalle Sommer Nielsen
Hi 2017-06-28 20:46 GMT+02:00 David Rodrigues : > The "final" keyworks make a "local scope" variable value "blocked to > rewrite" after instantiate it. > Okay, it sounds like a "const", and it is, but "not as we known it". I get that, but I still don't understand why you would forcefully need it

Re: [PHP-DEV] Final variables

2017-06-28 Thread David Rodrigues
​ Walter Parker ​ wrote:​ > ​ Constant may not have been the right word (or idea), but I agree with Kalle. We should use readonly as the keyword here and not final as the keyword. We can keep the same scoping rules so the following would work: >​ ​> function randomNumber() { ​>​ *readonly *$numb

Re: [PHP-DEV] Final variables

2017-06-28 Thread David Rodrigues
2017-06-28 13:59 GMT-03:00 Kalle Sommer Nielsen : > Hi David > > It seems like what you are looking for here is actually a constant[1]. > However constants do not support non scalar types, such as array or > objects, what would really solve it on the objects side of things > would be the introduct

Re: [PHP-DEV] Final variables

2017-06-28 Thread Kalle Sommer Nielsen
2017-06-28 19:37 GMT+02:00 Niklas Keller : > Arrays are supported, but not objects. Ah yes ofcourse, my apologies. -- regards, Kalle Sommer Nielsen ka...@php.net -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Final variables

2017-06-28 Thread Niklas Keller
2017-06-28 18:59 GMT+02:00 Kalle Sommer Nielsen : > Hi David > > 2017-06-28 18:10 GMT+02:00 David Rodrigues : > > Hello internals, > > > > Java supports the "final" keyword before a variable to determines that > this > > variables never change it reference. If I declare a variable as "final", > I

Re: [PHP-DEV] Final variables

2017-06-28 Thread Kalle Sommer Nielsen
Hi David 2017-06-28 18:10 GMT+02:00 David Rodrigues : > Hello internals, > > Java supports the "final" keyword before a variable to determines that this > variables never change it reference. If I declare a variable as "final", I > can only initialize that once, then I could not change it after (b

[PHP-DEV] Final variables

2017-06-28 Thread David Rodrigues
Hello internals, Java supports the "final" keyword before a variable to determines that this variables never change it reference. If I declare a variable as "final", I can only initialize that once, then I could not change it after (but I can manipulate the instance, without issues). There some s