Re: Re: Let's discuss enums!

From: Date: Tue, 22 Sep 2015 14:44:01 +0000
Subject: Re: Re: Let's discuss enums!
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-88406@lists.php.net to get a copy of this message
> The point I'm trying to make is that an enum's normalized > representation should be an integer, and that is also how it should be > serialized. It also happens to be how most other languages chose to > represent enums, and deviating from that will cause all kinds of pain > the minute you need to do type conversions between formats or > languages. You can always serialize things however you want. Using serialize() is just a convenience – there is absolutely nothing that prevents you from using a custom serialization routine. Note that while Java has built in serialization it is often not used, and instead libraries like Google's GSON are used. You register a type with hooks for serializing and deserializing, etc. It sounds like this is what you need anyway. Since built-in serialization happens differently in each language you'd probably want something custom in each language.

« previous php.internals (#88406) next »