Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88407 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51540 invoked from network); 22 Sep 2015 15:07:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2015 15:07:01 -0000 Authentication-Results: pb1.pair.com header.from=dan@dancryer.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=dan@dancryer.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dancryer.com from 178.79.130.57 cause and error) X-PHP-List-Original-Sender: dan@dancryer.com X-Host-Fingerprint: 178.79.130.57 server1.block8.net Received: from [178.79.130.57] ([178.79.130.57:57533] helo=li186-57.members.linode.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/9C-56639-49E61065 for ; Tue, 22 Sep 2015 11:07:01 -0400 Received: from mail-wi0-f171.google.com (mail-wi0-f171.google.com [209.85.212.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by li186-57.members.linode.com (Postfix) with ESMTPSA id 11D401198F for ; Tue, 22 Sep 2015 16:06:58 +0100 (BST) Received: by wiclk2 with SMTP id lk2so28658528wic.1 for ; Tue, 22 Sep 2015 08:06:57 -0700 (PDT) X-Received: by 10.194.236.74 with SMTP id us10mr17241073wjc.39.1442934417750; Tue, 22 Sep 2015 08:06:57 -0700 (PDT) MIME-Version: 1.0 References: <55FB4791.4040807@gmail.com> <55FB4DFC.2060204@domain.invalid> <55FB555C.9070701@gmail.com> In-Reply-To: Date: Tue, 22 Sep 2015 15:06:48 +0000 Message-ID: To: Levi Morrison Cc: internals Content-Type: multipart/alternative; boundary=089e0149426a67852c05205759d9 Subject: Re: [PHP-DEV] Re: Let's discuss enums! From: dan@dancryer.com (Dan Cryer) --089e0149426a67852c05205759d9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > You can always serialize things however you want. Using `serialize()` > is just a convenience =E2=80=93 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. > Whilst that might be the case with *serialize()*, by extension you also lose the convenience of being able to use *json_encode() *on an already properly structured object and immediately having a representation of that object ready to send over the wire. C#'s enums seem a good model to follow. 0-indexed by default, alternatively you can specify the first key to change to (for example) 1-indexed or specify all keys: enum Days {Sat=3D1, Sun, Mon, Tue, Wed, Thu, Fri}; --089e0149426a67852c05205759d9--