Hello,

I was trying to implement the result type from OCaml using enums, and
noticed that they can only carry int or string data, not arbitrary
data. Any specific reason for this?

Example:

    enum Result: mixed {
        case Ok = null;
        case Error = null;
    }

Error with:

Fatal error: Enum backing type must be int or string, mixed given in
/tmp/enum.php on line 3

More specifically, for this idiom to work, "Ok" needs to be mixed and
"Error" should be string.

OCaml idiom: https://ocaml.org/learn/tutorials/error_handling.html#Result-type

Olle

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

Reply via email to