Re: [PHP-DEV] enum flag backed enum

2025-09-06 Thread Rowan Tommins [IMSoP]
On 6 September 2025 01:47:35 BST, Rob Landers wrote: > >Interesting... but we don’t really have a way to say that a parameter or >return value must satisfy *any* constraints except that it be of a certain >type. Hmmm, I guess we have "true" and "false" as values that can be >returned/accepted b

Re: [PHP-DEV] enum flag backed enum

2025-09-05 Thread Rob Landers
On Fri, Sep 5, 2025, at 22:01, Rowan Tommins [IMSoP] wrote: > On 4 September 2025 15:50:08 BST, Rob Landers wrote: > >I think this is a fair observation and a fair question; but I think it is > >important not to have "magic". The power-of-two rule is to make it possible > >to work back how $en

Re: [PHP-DEV] enum flag backed enum

2025-09-05 Thread Rowan Tommins [IMSoP]
On 4 September 2025 15:50:08 BST, Rob Landers wrote: >I think this is a fair observation and a fair question; but I think it is >important not to have "magic". The power-of-two rule is to make it possible to >work back how $enum->value === 15 (0x) even if you are completely new to >the lang

Re: [PHP-DEV] enum flag backed enum

2025-09-04 Thread Larry Garfield
On Wed, Sep 3, 2025, at 7:20 PM, Morgan wrote: > On 2025-09-04 09:23, Marc B. wrote: >>> >>> Attempting to use a backed value that is not a power-of-two would result in >>> a compilation error. Bitwise operations are performed as though they’re >>> performed on a regular integer. >>> >>> What do

Re: [PHP-DEV] enum flag backed enum

2025-09-04 Thread Rob Landers
On Thu, Sep 4, 2025, at 15:56, Larry Garfield wrote: > On Wed, Sep 3, 2025, at 7:20 PM, Morgan wrote: > > On 2025-09-04 09:23, Marc B. wrote: > >>> > >>> Attempting to use a backed value that is not a power-of-two would result > >>> in a compilation error. Bitwise operations are performed as thoug

Re: [PHP-DEV] enum flag backed enum

2025-09-03 Thread Morgan
On 2025-09-04 09:23, Marc B. wrote: Attempting to use a backed value that is not a power-of-two would result in a compilation error. Bitwise operations are performed as though they’re performed on a regular integer. What do you think? I think what we actually would need is an EnumSet which

Re: [PHP-DEV] enum flag backed enum

2025-09-03 Thread Marc B.
Hi Rob, Am 3. September 2025 22:44:58 MESZ schrieb Rob Landers : >Hello internals, > >I would like to propose a new type of backed enum: flag. This is an >integer-backed enum that requires power-of-two values that can be combined >with the bitwise operators to be used as flags. > >In some core f