Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119328 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92511 invoked from network); 18 Jan 2023 18:33:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 18 Jan 2023 18:33:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 53A38180212 for ; Wed, 18 Jan 2023 10:33:28 -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=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FREEMAIL_REPLYTO_END_DIGIT,HTML_MESSAGE, 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-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 ; Wed, 18 Jan 2023 10:33:24 -0800 (PST) Received: by mail-pf1-f181.google.com with SMTP id w2so11511372pfc.11 for ; Wed, 18 Jan 2023 10:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Yk19RYQ2uo5dF0yn/wgjr2esczPquYxK4mT8NGPXC5E=; b=WdIkBbAx9DvqVr7iNIi8R8q+eeSsjez4K3uSzm7AqGEbB1kez2avNvpdowAz7vhZ5E cza4ECIzxpNV38/okfqNIaN61HX22NT8LduyH0W6tv3FVHs1aT6mbiM/uvx3yksIi7Xh fZT2a9Sh2Hx0hSf7j41GVnzr4BBTlI6pyNwE2fPIaP2DPYVzWA5HIkVda8EOMa4HSSVE CzTYPrTCf9Xxmqjr0y54GW+P/6z+Chmdv251NrZIkQtBzEv7EvP0CJzeDpwckzd5SQex Cj8bcG4dEfCg35/qqEDWgdBpQs+QEh+SxtAttWuZCWfeQFL5E0H3PZL3s7iRUr6SyE5O tAwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:reply-to:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Yk19RYQ2uo5dF0yn/wgjr2esczPquYxK4mT8NGPXC5E=; b=G0EQ2T4Zz+xkpaX1hn+m4N0v1UWN8ZRhI/hgXmgWIdqVi1YBIJKHCKibnsU/COkd6w /igJFcRPoMAMnlQadPJEw2StEc7XXVw22t8N2O1M4nAjMbmmKAeOZCDZ8kSQY/EyMZzO DE2AqyBgbDgfq+CXJ7Y9wl+O46PFV8HChOhXJcJEJVCvipOFay1ix/k1KRm/WMnaAtPw KF7d/9YdIti6V8Rwuq9wx9tGB9HWmil49+JSOyNGPd6v9YUot/92mjezsdnjrMnmocvi GdGKPmQOlqBI/ey7YZ2QuACJQf6eFOz5NjLosaGJLuDH7O8JEG0xNi58ZnqObUhLxWds Otlg== X-Gm-Message-State: AFqh2kqNFNhb+I1l7v0c9VgCStXc0e5KCYhSZ2JToybiSIstg/3KnZeE byTMMl4qqNmVu/MzLRbClM5OemGZXAa5fjNpHc0= X-Google-Smtp-Source: AMrXdXvH4A1/BnOmbQvKZiNgjn2yxc4mo1N2rYvHIEOjJHpSBBKLqQRXS8IWkLFxiiie3NdicyHJ6W0rRFBuhR/kDM4= X-Received: by 2002:a05:6a00:2992:b0:58d:b26a:6238 with SMTP id cj18-20020a056a00299200b0058db26a6238mr822310pfb.84.1674066803719; Wed, 18 Jan 2023 10:33:23 -0800 (PST) MIME-Version: 1.0 References: <04288995-54CE-41A4-BFFD-A7CF72F16D3F@gmail.com> In-Reply-To: Reply-To: autaut03@gmail.com Date: Wed, 18 Jan 2023 20:33:10 +0200 Message-ID: To: Claude Pache Cc: Kamil Tekiela , PHP Developers Mailing List Content-Type: multipart/alternative; boundary="0000000000002a851e05f28e0dea" Subject: Re: [PHP-DEV] [RFC] Path to Saner Increment/Decrement operators From: autaut03@gmail.com (Alex Wells) --0000000000002a851e05f28e0dea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 18, 2023, 19:57 Claude Pache wrote: > > > > Le 18 janv. 2023 =C3=A0 18:27, Kamil Tekiela a = =C3=A9crit : > > > > Strings should not be incrementable unless they are numeric strings. Th= e > > current "feature" is more like a bug from xkcd comic. > https://xkcd.com/1172/ > > > > But as there is a real need for a similar functionality, for example wh= en > > working with Excel, I would propose to add a class into the language th= at > > is able to calculate and iterate any bijective base system. It needs to > > have a clear functional spec and should support both increment/decremen= t > > operators as well as iterators. I see this as the only way out of this > > mess. This RFC needs to pass, but it cannot pass without an alternative > for > > people who actually use this "feature". > > For those that lack imagination about possible use cases, here is mine: > generating unique (in the scope of the request) alphabetic ids: > > function nextid(): string { > static $id =3D 'zz'; > return ++$id; > } > > But no over-engineering please: no class and no decrement equivalent (the > latter could be added in a separate RFC if it is really deemed useful), > just a plain function that replicate the current behaviour for strings of > the form /^[A-Za-z0-9]*$/, minus the bugs around the peculiar notion of > =E2=80=9Cnumeric string=E2=80=9D (e.g., "9E1" equivalent to 90). > > =E2=80=94Claude Classes and methods is the expected way of implementing standard library in an OO language. New APIs (such as the new Random api) use OO instead of functions and it makes more sense to use OO in this case too: there's likely a place for other methods too, like toBase(int $otherBase) etc. It would also be possible to use overloaded operators if needed. --0000000000002a851e05f28e0dea--