[PHP-DEV] Constants and Access Modifiers

2017-10-27 Thread Fleshgrinder
Hey Internals! We currently have a couple of things that are broken about constants, and I wanted to gauge if people are interested in a) fixing it as well as b) to get to know the root causes of these things. # 1 A constant defined in an interface cannot be overwritten in the class that impleme

Re: [PHP-DEV] Constants and Access Modifiers

2017-10-27 Thread Nikita Popov
On Fri, Oct 27, 2017 at 10:51 PM, Fleshgrinder wrote: > Hey Internals! > > We currently have a couple of things that are broken about constants, > and I wanted to gauge if people are interested in a) fixing it as well > as b) to get to know the root causes of these things. > > # 1 > > A constant

Re: [PHP-DEV] Constants and Access Modifiers

2017-10-28 Thread Fleshgrinder
On 10/27/2017 11:15 PM, Nikita Popov wrote: > PHP does not permit self-referencing constants. > > However, this is only checked when the constant is first accessed. In your > first example the constant is never accessed, so no error is thrown. This > has nothing to do with subclasses defining the

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-04 Thread Stanislav Malyshev
Hi! > My wording was maybe a bit wrong here, and I was biased by the fact that > I would like to see abstract constants. The fact that not everything can What is "abstract constant"? If you need something that can change, just use a method. Constant is meant to be a nice way to write something in

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-05 Thread Niklas Keller
> > Hi! > > > My wording was maybe a bit wrong here, and I was biased by the fact that > > I would like to see abstract constants. The fact that not everything can > > What is "abstract constant"? If you need something that can change, just > use a method. Constant is meant to be a nice way to writ

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-05 Thread Fleshgrinder
On 11/5/2017 1:03 PM, Niklas Keller wrote: >> >> Hi! >> >>> My wording was maybe a bit wrong here, and I was biased by the fact that >>> I would like to see abstract constants. The fact that not everything can >> >> What is "abstract constant"? If you need something that can change, just >> use a m

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-05 Thread Stanislav Malyshev
Hi! > An abstract constant is a constant that requires its value to be defined > later, like an abstract method that requires its implementation to be > defined later. It's not a constant then, and should be a method. > > The thing is that I want something that CANNOT CHANGE. I want to require

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-11 Thread Fleshgrinder
On 11/6/2017 1:44 AM, Stanislav Malyshev wrote: > Hi! > >> An abstract constant is a constant that requires its value to be defined >> later, like an abstract method that requires its implementation to be >> defined later. > > It's not a constant then, and should be a method. > No, because a me

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-11 Thread Rowan Collins
On 11/11/2017 18:39, Fleshgrinder wrote: On 11/6/2017 1:44 AM, Stanislav Malyshev wrote: From this link, it looks like const in Dart has pretty much nothing in common with const in PHP, besides name, so in the interest of avoiding confusion, I would not discuss it in the same topic. Yes, Dar

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-11 Thread Stanislav Malyshev
Hi! > Yes, Dart has a different understanding of const, which is exactly why I > posted it for you guys. In the hope that it helps to get more different > views on the topic. Currently you are too concentrated on how it is > implemented in PHP at this time, and argue that it is impossible to > div

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Fleshgrinder
On 11/12/2017 12:44 AM, Stanislav Malyshev wrote: > Hi! > >> Yes, Dart has a different understanding of const, which is exactly why I >> posted it for you guys. In the hope that it helps to get more different >> views on the topic. Currently you are too concentrated on how it is >> implemented in

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Tony Marston
wrote in message news:549c4634-ac38-41d3-ab43-f816a9f2b...@fleshgrinder.com... On 11/12/2017 12:44 AM, Stanislav Malyshev wrote: Hi! Yes, Dart has a different understanding of const, which is exactly why I posted it for you guys. In the hope that it helps to get more different views on the to

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Fleshgrinder
On 11/11/2017 9:51 PM, Rowan Collins wrote: > On 11/11/2017 18:39, Fleshgrinder wrote: >> On 11/6/2017 1:44 AM, Stanislav Malyshev wrote: >> >>>  From this link, it looks like const in Dart has pretty much nothing in >>> common with const in PHP, besides name, so in the interest of avoiding >>> con

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Alice Wonder
On 11/12/2017 01:38 AM, Tony Marston wrote: wrote in message news:549c4634-ac38-41d3-ab43-f816a9f2b...@fleshgrinder.com... On 11/12/2017 12:44 AM, Stanislav Malyshev wrote: Hi! Yes, Dart has a different understanding of const, which is exactly why I posted it for you guys. In the hope that i

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread li...@rhsoft.net
Am 12.11.2017 um 10:50 schrieb Alice Wonder: On 11/12/2017 01:38 AM, Tony Marston wrote: Just because some languages use a corrupt definition of "constant" is no reason for PHP to do the same. A constant has a value which, once defined, cannot be changed. It is not logical to define a constant

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Rowan Collins
On 12/11/2017 09:49, Fleshgrinder wrote: Other languages allow you to have a contract on fields. class A { const FOO: int = 42; } class A { final static $foo: int = 42; } These are basically the same, as you already said. However, I added a contract to both of them. Yes, I wondered

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread li...@rhsoft.net
Am 12.11.2017 um 19:25 schrieb Rowan Collins: On 12/11/2017 09:49, Fleshgrinder wrote: There is one thing that differs for the const and the field: a const value must be known at compile time, whereas a field value does not. An important difference! class A { abstract public const FOO: in

Re: [PHP-DEV] Constants and Access Modifiers

2017-11-12 Thread Fleshgrinder
On 11/12/2017 7:25 PM, Rowan Collins wrote: > On 12/11/2017 09:49, Fleshgrinder wrote: >> Other languages allow you to have a contract on fields. >> >> class A { const FOO: int = 42; } >> class A { final static $foo: int = 42; } >> >> These are basically the same, as you already said. How