Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108764 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53494 invoked from network); 25 Feb 2020 23:03:54 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Feb 2020 23:03:54 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 152181804DF for ; Tue, 25 Feb 2020 13:21:24 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) (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 ; Tue, 25 Feb 2020 13:21:23 -0800 (PST) Received: by mail-lj1-f182.google.com with SMTP id d10so491445ljl.9 for ; Tue, 25 Feb 2020 13:21:23 -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=Lyrnqojr0aRt9HjPqK8RQaRVC9LW/ppZKPPCJeWK9Cs=; b=hyeaH8+LusE+kRtnOAaojjzhhfOwtC62MKbkyVax2pXZxWXQrvr2TBolWD3kdN5eia C+4KSx92wPm+AgP9qqskH1cOTwhvv9N/xFq1vVEN54y7nc3jsG1axAOA84d6zygIF+KF ZTtK1W2YSl8YelqCuKh9BBr5zF+LjciaM8Mbtf+ivlYM3Bpv3tc36HkdIyyR/rbDakwS l8nLogsN+dKUvtIqH5I/UQ+kQ4wX5YMT8bJtlfTjxrKskrdq+9+53HNsN/T3wzgxWYQf BO3wEJrIIgNlq3IDNvU/Yu3WCSqDRRMcgf6HA1tpMHVV/b1t0XV8/HZP6MF/I7FvIJ/Y Tz6Q== 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=Lyrnqojr0aRt9HjPqK8RQaRVC9LW/ppZKPPCJeWK9Cs=; b=LjOTBX9+1D2x0WOmor47sYJ8J6yMWJYgIqajjLE8k5QesIDIccXr+5mF4neIlc4ZVw Em+s3BjuVvrW2i9N5XVXgYiE3GjDjsaiBwfCe3vJs+DJ78r37rJhzATQx1+hBiZV8Vwy S5cFPBb4i2SwuIs+5VgswYFPZ918CYyDXEpVHUGAgS9MwHLGfpX4h8nUGgWNuqTzzjVb meH+E2GjopmGh+7MYiSC1vn6+CmZIO97deICGHwIWsDxknDV3V5rESK/CkI2NSqQ8KUE yjBa9hs0COc7cLm3dNl84qonrk/yk4ESraZd6OluZa8oc9BS3jUw4ISU4YASfnQbRdz2 cd2A== X-Gm-Message-State: APjAAAXeftXsjoQZRS8c8B9bwtCwhHQeqB2YmUYsCll8m8E8paPhPXKc icHuzHAttWUs9UHqX7h4j5bRaHEYcGtz+4xeKe2904k3 X-Google-Smtp-Source: APXvYqw6iLUqi/YDUeH7cp7tSSzondFzRXHx5eOn/IfZRfOhPQITYAyFCV3GqsO2l9VKoFm9U+A0c1qZ8gbIuCkcwmM= X-Received: by 2002:a2e:93c5:: with SMTP id p5mr589825ljh.192.1582665680923; Tue, 25 Feb 2020 13:21:20 -0800 (PST) MIME-Version: 1.0 References: <37fe0afd-bcfd-4719-9261-3fa1e758b6ed@www.fastmail.com> In-Reply-To: <37fe0afd-bcfd-4719-9261-3fa1e758b6ed@www.fastmail.com> Date: Tue, 25 Feb 2020 22:21:04 +0100 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000b5b17f059f6d119b" Subject: Re: [PHP-DEV] Re: [RFC] token_get_all() TOKEN_AS_OBJECT mode From: nikita.ppv@gmail.com (Nikita Popov) --000000000000b5b17f059f6d119b Content-Type: text/plain; charset="UTF-8" On Tue, Feb 25, 2020 at 5:59 PM Larry Garfield wrote: > On Tue, Feb 25, 2020, at 9:59 AM, Nikita Popov wrote: > > On Thu, Feb 13, 2020 at 10:47 AM Nikita Popov > wrote: > > > > > Hi internals, > > > > > > This has been discussed a while ago already, now as a proper proposal: > > > https://wiki.php.net/rfc/token_as_object > > > > > > tl;dr is that it allows you to get token_get_all() output as an array > of > > > PhpToken objects. This reduces memory usage, improves performance, > makes > > > code more uniform and readable... What's not to like? > > > > > > An open question is whether (at least to start with) PhpToken should be > > > just a data container, or whether we want to add some helper methods > to it. > > > If this generates too much bikeshed, I'll drop methods from the > proposal. > > > > > > > I think this proposal is in a pretty decent shape now, and I'd like to > move > > it to voting soon. The only remaining open question is whether we want to > > add any additional predefined methods. As the class can now be extended, > > every library can add their own methods, but there might still be value > in > > providing some things by default, primarily for performance reason. For > > example, the proposed is() method can be a good bit more efficient when > > implemented directly in extension code. > > > > Any feedback on this point? > > > > Nikita > > Seems good to me in its current state. > > One last thought I had: in its current form, it *seems* like it would be > possible, in concept, to create tokens directly via the constructor > (ignoring the positional values), then have a generic render command you > can apply to a list of them to use for code generation. I know that's not > the intent here, but in concept is what I described possible? > Sure, that works. You can construct your own tokens and the "render command" should actually be as simple as implode(array_column($tokens, 'text')). Nikita --000000000000b5b17f059f6d119b--