Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117849 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69403 invoked from network); 3 Jun 2022 11:41:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jun 2022 11:41:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C1E3818037E for ; Fri, 3 Jun 2022 06:26:28 -0700 (PDT) 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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 3 Jun 2022 06:26:28 -0700 (PDT) Received: by mail-ot1-f44.google.com with SMTP id w19-20020a9d6393000000b0060aeb359ca8so5525054otk.6 for ; Fri, 03 Jun 2022 06:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Hwju+qLqMeMEDbZpEL7jY5B9sUwjLs80wBFDQ8f4s3k=; b=H/qBNZFMn8ZolXm2H2h1ov3LoaKJQGDTreyjL32Wa2eJagELLS/iVxOzX+MU/QdzLu HfO3GZK1ueJ243WG/9cRBRPhqaFRCntthCBr8/Bk+Yj6jiHOV1xBd12Q4V/JEZFN09dM qJxoWThPuxl61ZlqNYL6rwTh9ZxswQZHrAzh/0+aBDFm9OmmTARnaIg5J8auPoTo4VPq okSgztTo35VXnia/eVNzsX2xj2e8k8ZfrZCjK83yRU8KMaylnPIcizF6HkkM3mGKwmgQ dYxxYSDoEREcoawBa8u1X6bwMlvO/lbeBr9+Nh0ElJ7HKfJsAG70CKrJ36IeCLdOHWE0 YUaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Hwju+qLqMeMEDbZpEL7jY5B9sUwjLs80wBFDQ8f4s3k=; b=rctyznkYnxrQtXepXLmQCbRDfXE2Rs9+yXLbqHqv/s/Qlugs2eJ7QQ7uoEfUTNZost P9ETp/mMY6YZOJGaPA85IgdlzhQdi/tvjUvSeuZB9PeF67dvNZTN/K1iQgIXCA0i73Pe kFpg+UZPNeBf3FrBk8L8a7TcyRlMrDt+eyhyrak7L0qKUtkOJmOLCczIzPcqfX3VkZfK OBmAeBMgNFwpw7wFX/oBsG0AblU5pCx9Xj5vfgAnxRstKYgpxXjfz3LpeuJXV8mrmnqh t5lmpCiadFnBT03QLDBIoyV3+QoukR52jXSGu5GgJt5dgGHDLXk4WKfTR/+fvCpG/4RN D1QA== X-Gm-Message-State: AOAM533yJG1UyY24uTjXbT8mcZEHnTf+MYnlwceVNQDrc5RtakI96fJd efosPyO6FGmVA3wK9o3vuOE6SiBBXErDwCRV2SgrHe8e/iAdkZR2 X-Google-Smtp-Source: ABdhPJx0DdJHpbWzSaKGXChjqdYDdpNhN4dwQuHZjeI4m+aHhTte2kkk0eYS2/pNGauopcIzkTyQd36fGX9vFhKv4Bc= X-Received: by 2002:a9d:7614:0:b0:60b:c4c9:1de5 with SMTP id k20-20020a9d7614000000b0060bc4c91de5mr2792494otl.349.1654262787727; Fri, 03 Jun 2022 06:26:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jun 2022 09:26:16 -0400 Message-ID: To: Ilija Tovilo Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Under discussion] Fetch properties in const expressions From: landers.robert@gmail.com (Robert Landers) On Thu, Jun 2, 2022 at 8:17 AM Ilija Tovilo wrote: > > Hi Nikita > > > This looks like a reasonable addition. > > > > Could there be any expectation that if -> works, ?-> does as well? > > Possibly. The implementation was simple enough so I'll add support for > completeness. > > --- > > Hi C=C3=B4me > > > It is not clear to me why this allows using -> on enums but not on othe= r objects. > > The RFC *does* allow using -> on all objects. From the RFC: > > > As mentioned, the primary motivation for this feature are enums. Howeve= r, the > > implementation for supporting new is identical and I don't believe > > arbitrarily restricting how -> can be used in this context makes sense. > > > Can you clarify why the following is not allowed: > > > > > > > $a =3D new Thing(); > > > > class C > > { > > protected $b =3D $a->var; > > static $staticobj =3D new Thing(); > > function f($p =3D self::$staticobj->var) {} > > } > > `protected $b =3D $a->var;` is not allowed because there can't be local > variables in the context of context expressions. `function f($p =3D > self::$staticobj->var) {}` is not allowed because static variables > aren't supported in constant expressions. Your examples would already > fail today without ->. > > Ilija > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > The RFC *does* allow using -> on all objects. From the RFC: So, how does this change our mental models when writing PHP? For example, I generally consider `const` to be a "compile-time" constant (ie, generated/created before any code is actually executed). So would this allow code to actually execute before any other code (ie, by putting code in a __get()) and thus cause issues due to database drivers and etc to not be loaded yet -- or cause them to be loaded prematurely?