Re: Any reason why backed enums are limited to int and string only?
| From: | Rowan Tommins | Date: | Wed, 31 Mar 2021 18:51:19 +0000 |
| Subject: | Re: Any reason why backed enums are limited to int and string only? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-113884@lists.php.net to get a copy of this message | ||
On 31/03/2021 19:44, Olle Härstedt wrote:
enum Result: mixed {
case Ok = null;
case Error = null;
}
Sounds like what you're looking for is not "pure" enums, but Algebraic Data Types. Larry and Ilija have a grand plan for adding those, but there's a few steps to go yet: https://wiki.php.net/rfc/adts
The current enum values are just constants for simplifying serialization and lookup (translating to a code or database ID).
Regards,
--
Rowan Tommins
[IMSoP]