Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113397 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 74347 invoked from network); 5 Mar 2021 10:01:09 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Mar 2021 10:01:09 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2AA0D1804B8 for ; Fri, 5 Mar 2021 01:52:07 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 5 Mar 2021 01:52:06 -0800 (PST) Received: by mail-lf1-f44.google.com with SMTP id m22so2593509lfg.5 for ; Fri, 05 Mar 2021 01:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KBJtSm05X+AW7/r+Fyy6XC3VWnj8F9YvAurPboqar68=; b=kb3QSHP7eXm4nfldStJmPsEjRcOh7A9g1WVhYrP8n3Nfv5GLhy6y7y4dUSsN0YrBfM V3fHmyf1twBSP/duHLFCqPPfZtBx5SVUsyGwC+VZsaNe2THmFmTb4dRfHLE0Ow1Cb4uF /oXrG0X59SMAIlh1gAiNUF8e6eD11ekclvu8g0XsGezzbJOfi9B9z8bDCYA49AIePVpZ 3eIKp8yaUGp2PEPGtlzvrGES5aosU7CLWG1dfpsII1YNhwEYZvN+BFi4s78WSZC2Qbxo CZY+VjhGM3Eb/1GZb/NAVA4TVT1aYtxwJVOexnxe8MZfPqhrs5bHfOdsvBpXVhjtcLxu wz9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KBJtSm05X+AW7/r+Fyy6XC3VWnj8F9YvAurPboqar68=; b=aTGQoVd0jKcl/NqNgd6+9Kfx20rT4sQgELBT6OvyJjVVL2j2hRI4BegIkhbZ4GRkiF JPM2PvwB45PUNtsMpLekkdUYX9yPlp2Wm+IEHi7YD7sxJCJTmScOMszi5jhhSxhfMT7h 2qe6HEDsF0Ms6zZ4xNLss3ck++qBG5XaI3DhdIosfXrZ9cx9JvdSKVEeT/zX2LLR33S0 QCXaiPpgsM1bUHRDVU/mBcgyrUOpQskNFOcUe49RaOa3zkOB3LcpQopRCJLX707ivM4m dZnLqonWM5lw5J4VhMmmxWUcU41RkEFfjN3+NoMpNADixXIRNOZkfFxE+PvnxoDKeACV JI4w== X-Gm-Message-State: AOAM531FJjjd0zwORNQG0Xr8GxM6+x1nLfiPVQjGLdUHMLGF9Ng80cVt 1aLZwVE1o4wBpZIfrpWGuoWNKGrOW4j53DdB8Us= X-Google-Smtp-Source: ABdhPJx9BBpZvyVewxoi6WycTk+HUBYON3O+JuECHzz+gQtGFVs5+uRuHb7wYtzXOhe6ZCox6ljF9hiEXNDY+guXj+E= X-Received: by 2002:a05:6512:3a86:: with SMTP id q6mr5382195lfu.286.1614937921815; Fri, 05 Mar 2021 01:52:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 5 Mar 2021 10:51:45 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000002a0a0d05bcc709e9" Subject: Re: [PHP-DEV] [RFC] New in initializers From: nikita.ppv@gmail.com (Nikita Popov) --0000000000002a0a0d05bcc709e9 Content-Type: text/plain; charset="UTF-8" On Thu, Mar 4, 2021 at 5:26 PM Larry Garfield wrote: > On Thu, Mar 4, 2021, at 7:53 AM, Nikita Popov wrote: > > > I've added a section that describes reflection methods. It works exactly > as > > you say. > > > > There is one interesting case though: How should > > ReflectionObject::newInstanceWithoutConstructor() work? In the current > > implementation, it will still evaluate the property defaults, including > new > > expressions. This makes sense to me, but I can also see an argument that > > this method should not evaluate them -- however, in that case I believe > it > > should not initialize any properties at all (leave them in > "uninitialized" > > state). Populating property default values depending on what kind of > > expression they contain seems like a no-go to me. > > > > @Ben Ramsey: Yes, it's possible to use nested new. Generally, all > supported > > constant expressions can be freely combined. > > > > Regards, > > Nikita > > Would that then end up allowing enum cases to have an object backing value? > > enum Suit { > case Hearts = new Heart; > case Spades = new Spade; > } > > Or is there something else that would prevent that? (I know Ilija ran > into some complications there.) I believe enums enforce the limitation to strings and integers to allow an efficient mapping from backing value back to enum. If we added support for object array keys then we could theoretically support an object backing value -- but I don't really see why we should, or what that would be useful for. (Worth noting that this RFC does not introduce objects into initializer expressions -- the enum RFC does that. This RFC then removes the enum-only limitation.) Regards, Nikita --0000000000002a0a0d05bcc709e9--