On Wed, Dec 30, 2020, at 6:27 AM, Rowan Tommins wrote:
> On 28/12/2020 20:21, Larry Garfield wrote:
> > After considerable discussion and effort, Ilija and I are ready to offer 
> > you round 2 on enumerations.
> 
> 
> Thank you both, again, for all your efforts. I'm pleased to say that I 
> like this draft even more than the last one. :)
> 
> A couple of points that occurred to me reading through:
> 
> - The magic methods section lists __call as allowed, but not 
> __callStatic; was this deliberate, or just an oversight?

More oversight; the reasons for not including it initially aren't really good 
reasons, so we'll unblock that.

> - Under Future Scope, the "Grouped Syntax" sub-section says "That would 
> only work on the simple, non-primitive-backed case with no methods 
> defined [...] it is unclear how common that will be in practice" This 
> caveat doesn't apply to the current proposed syntax, and should perhaps 
> be re-visited.
> 
> Given that this is currently a legal declaration:
> 
> class Suit {
>    const Hearts = 'H', Diamonds = 'D', Clubs = 'C', Spades = 'S';
> }
> 
> It seems fairly reasonable for the enum version to allow the same syntax:
> 
> enum Suit: string {
>    case Hearts = 'H', Diamonds = 'D', Clubs = 'C', Spades = 'S';
> }
> 
> Or, for a non-scalar enum:
> 
> enum Suit {
>    case Hearts, Diamonds, Clubs, Spades;
> }

That's partially left over from when we had per-case methods, where grouping 
would be highly fugly.  However, I'm still advocating for tagged unions (in a 
future step) having per-case methods, and that would make the grouping syntax 
fugly again.  It's trivial to add later, so for now I think it's best to skip.  
If we find later on it doesn't get in the way of anything it's an easy addition.

--Larry Garfield

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

Reply via email to