Hi Davey
On 29.03.23 16:31, Davey Shafik wrote:
The issue of contention here is that inheritance isn't the correct mechanism for reusing
enum definitions to expand on them. What about allowing "use" syntax like
traits?
enum HttpErrors {
case HTTP_STATUS_400;
case HTTP_STATUS_401;
Hi Rokas,
On Thu, 30 Mar 2023 at 08:36, Rokas Šleinius wrote:
>
> On Wed, 29 Mar 2023 at 18:40, Larry Garfield wrote:
> >
> > 1) Please don't top-post.
>
> Am I doing it right now? I've never been on a mailing list.
You're replying in the preferred manner, yes. Quoting only the needed
amount an
Hi
On 3/29/23 16:31, Davey Shafik wrote:
The issue of contention here is that inheritance isn't the correct mechanism for reusing
enum definitions to expand on them. What about allowing "use" syntax like
traits?
enum HttpErrors {
case HTTP_STATUS_400;
case HTTP_STATUS_401;
…
}
On Wed, 29 Mar 2023 at 18:40, Larry Garfield wrote:
>
> On Wed, Mar 29, 2023, at 2:25 PM, Rokas Šleinius wrote:
> > First, I'm pretty sure I agree now that enums should *not* be
> > `extend`-ed as regular classes, there's a fundamental difference as
> > you state - the extended enum is a fundament
On Wed, Mar 29, 2023, at 4:28 PM, Mark Baker wrote:
> Another benefit of this approach would be to allow the inclusion of
> multiple enums, in the same way that we can include multiple traits.
>
>
> enum HttpErrors {
>
> case HTTP_STATUS_400;
>
> case HTTP_STATUS_401;
>
> …
>
> }
On 29/03/2023 16:43, Mark Baker wrote:
On 29/03/2023 16:31, Davey Shafik wrote:
On Mar 29, 2023, at 06:56, Rowan Tommins
wrote:
On Wed, 29 Mar 2023 at 14:22, Rokas Šleinius
wrote:
Ok so I am trying to find the argumentation here:
This is by design.
The point of enums is to be limiting
Hi
On 3/29/23 13:01, Rokas Šleinius wrote:
There's a hypothetical (based on a similar real world problem that I
am facing) example for the use of extending enums in the OP.
And I don't suppose Tim was arguing for not allowing enum
extendability, but rather contributing a real world example wher
Hi
On 3/29/23 12:41, Christian Schneider wrote:
And to give a specific example from PHP 8.3: As part of the Randomizer additions RFC
(https://wiki.php.net/rfc/randomizer_additions), PHP 8.3 got its first "natively
included" enum (\Random\IntervalBoundary). This enum works together with the new
On Wed, Mar 29, 2023, at 2:25 PM, Rokas Šleinius wrote:
> First, I'm pretty sure I agree now that enums should *not* be
> `extend`-ed as regular classes, there's a fundamental difference as
> you state - the extended enum is a fundamentally different THING as it
> can hold different values - when a
On Wed, 29 Mar 2023 at 15:26, Rokas Šleinius
wrote:
> Invoking it must provide a unique ErrorCode.
The concept of "uniqueness" only makes sense within a certain context - the
CMS easily create these two enums:
enum HttpErrorCode: int extends ErrorCode {
case NotFound = 404;
}
enum SQLErrorC
On 29/03/2023 16:31, Davey Shafik wrote:
On Mar 29, 2023, at 06:56, Rowan Tommins wrote:
On Wed, 29 Mar 2023 at 14:22, Rokas Šleinius wrote:
Ok so I am trying to find the argumentation here:
This is by design.
The point of enums is to be limiting.
This is clearly an assumption. That state
> On Mar 29, 2023, at 06:56, Rowan Tommins wrote:
>
> On Wed, 29 Mar 2023 at 14:22, Rokas Šleinius wrote:
>
>> Ok so I am trying to find the argumentation here:
>>> This is by design.
>>> The point of enums is to be limiting.
>> This is clearly an assumption. That statement is not in the doc
First, I'm pretty sure I agree now that enums should *not* be
`extend`-ed as regular classes, there's a fundamental difference as
you state - the extended enum is a fundamentally different THING as it
can hold different values - when an enum's sole purpose is to hold one
of the set of values.
That
On Wed, 29 Mar 2023 at 14:22, Rokas Šleinius wrote:
> Ok so I am trying to find the argumentation here:
>
> >This is by design.
> >The point of enums is to be limiting.
>
> This is clearly an assumption. That statement is not in the docs or
> RFC, nor such an oversimplification makes logical sens
Ok so I am trying to find the argumentation here:
>This is by design.
>The point of enums is to be limiting.
This is clearly an assumption. That statement is not in the docs or
RFC, nor such an oversimplification makes logical sense to me, but
maybe you have a source to back it up..?
>Re: proble
On Wed, 29 Mar 2023 at 13:30, G. P. B. wrote:
> On Wed, 29 Mar 2023 at 09:31, Rokas Šleinius wrote:
> > Enums were implemented as final so they cannot be extended nor can extend
> > anything else.
> >
>
> This is by design.
> Enumerations are in type theory parlance sum types.
> Objects in PHP,
On Wed, 29 Mar 2023 at 09:31, Rokas Šleinius wrote:
> Enums were a very useful addition to PHP, however one aspect of them is
> neither
> explicitly documented - or seemingly even talked about.
>
> Enums were implemented as final so they cannot be extended nor can extend
> anything else.
>
This
Hi!
There's a hypothetical (based on a similar real world problem that I
am facing) example for the use of extending enums in the OP.
And I don't suppose Tim was arguing for not allowing enum
extendability, but rather contributing a real world example where
users who were having some totally lega
Am 29.03.2023 um 11:55 schrieb Tim Düsterhus :
> On 3/29/23 11:42, Sebastian Bergmann wrote:
>> Am 29.03.2023 um 11:31 schrieb Rokas Šleinius:
>>> I wouldn't say removing the final attribute from enums actually "breaks"
>>> any functionality.
>> I am with Marco on this: removing the "finality" fro
Hi
On 3/29/23 11:42, Sebastian Bergmann wrote:
Am 29.03.2023 um 11:31 schrieb Rokas Šleinius:
I wouldn't say removing the final attribute from enums actually "breaks" any
functionality.
I am with Marco on this: removing the "finality" from enum would be a
major backward compatiblity break as
Am 29.03.2023 um 11:31 schrieb Rokas Šleinius:
I wouldn't say removing the final attribute from enums actually "breaks" any
functionality.
I am with Marco on this: removing the "finality" from enum would be a
major backward compatiblity break as it breaks a fundamental assumption
about enums
> BC break
Hm, do you really think so? I wouldn't say removing the final
attribute from enums
actually "breaks" any functionality.
It WOULD allow some potentially illicit hacking to the end users of
our code, that's
true. I'd say a minor possibility of impact.
And anyway, isn't that what got you
Hey Rokas,
The idea of declaring an enum `abstract` is potentially worth exploring
(I'm not convinced, but go for it), but beware that removing the implicit
`final` from ENUMs is a BC break, since it breaks the assumption that an
ENUM is a sealed type.
If you design a proposal now, you need to co
> to restrict options within a certain range.
Okay that's an aspect of enums that I never gave much thought to, but
you're completely right.
However to be explicit about that aspect of functionality one would
then have to also be
allowed to define final enums.
That way you still have both options
On Wed, Mar 29, 2023 at 10:31 AM Rokas Šleinius wrote:
>
> Enums were a very useful addition to PHP, however one aspect of them is
> neither
> explicitly documented - or seemingly even talked about.
>
> Enums were implemented as final so they cannot be extended nor can extend
> anything else.
>
>
The point of an ENUM is precisely to restrict options within a certain
range.
Assume you declared `ErrorCode` with `SOMETHING_BROKE` and `PEBKAC` as
possible enumeration values.
If you can (somewhere, anywhere in the code) check `instanceof ErrorCode`,
then you know it can only be `SOMETHING_BROK
Enums were a very useful addition to PHP, however one aspect of them is neither
explicitly documented - or seemingly even talked about.
Enums were implemented as final so they cannot be extended nor can extend
anything else.
>From a user perspective it's surprising - and actually limiting.
USAGE
27 matches
Mail list logo