On Fri, Aug 16, 2024, at 5:01 PM, Bilge wrote:
> On 16/08/2024 22:51, Gina P. Banyard wrote:
>> On Friday, 16 August 2024 at 22:01, Bilge <bi...@scriptfusion.com> wrote:
>>> 
>>> 
>>> On Fri, 16 Aug 2024, 20:57 John Coggeshall, <j...@coggeshall.org> wrote:
>>>> 
>>>> I'm not seeing an obvious upside to forbidding straight out `__toString()` 
>>> 
>>> I tend to agree, but Crell will drive by in a minute to drop some 
>>> philosophical nonsense about why we're all wrong :^)
>> 
>> If you could avoid disrespecting a contributor to the project, this would be 
>> appreciated.
> To be clear, I have nothing but love and respect for Larry.
>
> Cheers,
> Bilge

I appreciate that. :-)

To the original question, there's two reasons that __toString() was 
deliberately omitted from enums:

1. To discourage their use as "fancy strings".  Enums are their own type, 
independent of any other.  Making them usable as 95% strings partially defeats 
their purpose.

2. We still intend to add associated values to enums at some point (aka ADTs, 
aka tagged unions), and... we're not really sure yet if that will impact 
__toString() at all.  It may, it may not, we don't know.  So for now we're 
keeping our options open by disallowing __toString(), in case it ends up being 
needed for some ADT-related behavior in the future.

Point 2 will, hopefully, resolve itself in time once we can get ADT support in. 
 Point 1 will remain, however.

--Larry Garfield

Reply via email to