Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86151 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84641 invoked from network); 10 May 2015 20:00:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2015 20:00:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.169 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.213.169 mail-ig0-f169.google.com Received: from [209.85.213.169] ([209.85.213.169:37028] helo=mail-ig0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/B0-10618-0D8BF455 for ; Sun, 10 May 2015 16:00:17 -0400 Received: by igbsb11 with SMTP id sb11so55740150igb.0 for ; Sun, 10 May 2015 13:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=aCwZLPCadD/L7eZy0/DWuPKVoGCicNfgMygZmX1sSzE=; b=FvTr/Nmn0f2SLBhWRlirikwlpRXlHhYpt0XNDKL7HCBHRvMfxIdEoN+3G8RtLh9Fmp ZrxJjN4l8WS9loKDm11Zab20ET318CPCghKLoEVxJosOMjnFJEmPKVkZG1jm4rBiM/u9 U4C2KQatbzlVb+tOkzqkHqRXu3BrveAvXxdWQyJJLnDBKuW/GbmuwZJckQQCsEmwg9zp C3R32teYDRL43/JbuUHgcyqHw1mu6LS4bql+8dcmdYrHE6I/+EPNAkBMumhGu4t8xw5m 1EXdINDUCF/QWTCxvMUM6gpJnoycWwIxMq7WagPhoN8blbtact0VQNrpC9gepLf81FZN uhQQ== MIME-Version: 1.0 X-Received: by 10.107.10.79 with SMTP id u76mr9055136ioi.79.1431288013879; Sun, 10 May 2015 13:00:13 -0700 (PDT) Sender: morrison.levi@gmail.com Received: by 10.79.98.67 with HTTP; Sun, 10 May 2015 13:00:13 -0700 (PDT) In-Reply-To: References: <71A78449-A62C-400D-A01F-5668930A7BED@ajf.me> <554BDC4B.2010808@gmx.de> Date: Sun, 10 May 2015 14:00:13 -0600 X-Google-Sender-Auth: K5_opP7PqZPGUcDpEbg1xeIrst8 Message-ID: To: Pierre Joye Cc: Nikita Popov , Christoph Becker , Dmitry Stogov , Andrea Faulds , Julien Pauli , Derick Rethans , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Thoughts on C version supported for PHP-Next From: levim@php.net (Levi Morrison) A feature of C11 that would be useful is anonymous unions: struct zval { union { long lval; double dval; }; enum { IS_LONG, IS_DOUBLE } type; }; int main(void) { struct zval zv; zv.lval = 1; zv.type = IS_LONG; return 0; } Again, this is a C11 feature. It is supported by clang, gcc and MSVC. Also note that if you use designated initializers from C99 you can directly initialize it like so: int main(void) { struct zval zv = { .lval = 1, .type = IS_LONG }; return !(zv.lval == 1); } If we are going to have a repository of features this is definitely one I'd like to test since the biggest three compilers all support it and I'd like to see how far the support reaches. Similarly anonymous structs would be useful as well. One specific place I am aware of is the _zend_function union that has a struct named common. If you make this struct anonymous then you can directly access the struct's properties just like you can with _zend_internal_function and _zend_op_array. This makes the polymorphic nature of these structures a bit easier to deal with.