Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115131 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26620 invoked from network); 24 Jun 2021 19:33:42 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Jun 2021 19:33:42 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E41CA1804CC for ; Thu, 24 Jun 2021 12:52:29 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (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 ; Thu, 24 Jun 2021 12:52:29 -0700 (PDT) Received: by mail-qk1-f181.google.com with SMTP id x1so12758040qkp.7 for ; Thu, 24 Jun 2021 12:52:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=7E6Ji1VNAuOaymkI+PBoIQodyZY605nyMbPbRWj5he4=; b=zqCTz8fZ2nqm1kM3KpxnEqGDkjUFuO8PJWl44LLvXGYCTGb+nn4/EfhP1wu9Avx4jK n7BGCJcoLyVleaHQl7dxp08lC0gSqA/KO4vflIZ+QF4xR0EWRZQvoNLiuaB1YdRlx+wR 1zo+1492GIHJG2lFr82XwzVF80YXyKc6nIfo744jprfibWIo5fxeGUi/YkGDYkp1bKmT cWinCuy9OHmpdn1FNGsy6qlmBl1+vcFaeUzzd24vbcwdJ8dq0p/N+0udotNEGJ2mnAs4 UbTCg/w5xqGuMI0imD6iXpltLxeAycrkNLPa3EGBLNMJgfftnp8wylZ2tRah4HlzI8p+ x7Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=7E6Ji1VNAuOaymkI+PBoIQodyZY605nyMbPbRWj5he4=; b=lX3jmWyN5fdrsrIdrowM6D50kk5NkdejWxltcnF847NysELF71nNYP5BYqVRLzSKvt U5IFUcy5SacRn6r5qXq0aWXPOgRCA1te3IT/tgAyANiszI4vLix1ZinyzHPAPfwnfhfn 2mpNG+2PbR9q7jvRSOhwf9R8hH+1wlemC53yuGex9/ceeS7RjBMfzrpoHvLjo25sCSJF ZrUa2wDtul6VzWPfDH9+37UBHghUSSgHoKadx/mmHarmxPzfzZo2mZCdTWMWZEOT1ucd dj8FTYXKahpowcJKKqy9ACMoZclOiL4ewiF4s4Qz1SLCQHmQPdknUXCs0VF8NYo8qTD1 dhPg== X-Gm-Message-State: AOAM533DXFlfk9QfZ437hGwqMLDyKEA3BkOoiKdMxv3umbXWKOcx+JPs 9LvjeAsEqtjgBkvKA0w3FpzRtA== X-Google-Smtp-Source: ABdhPJwBz6368vNSp6HCQzpamvhM1zm7yjdvjxnb/yUAK2t8q3vHEIvukjCiz1y7031FEVKiGSeRUA== X-Received: by 2002:ae9:f405:: with SMTP id y5mr7453110qkl.462.1624564347093; Thu, 24 Jun 2021 12:52:27 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id l9sm953778qtk.51.2021.06.24.12.52.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jun 2021 12:52:26 -0700 (PDT) Message-ID: <2E3588E2-A218-4A23-9E23-20E486789D7D@newclarity.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_4E5172BD-507F-4103-A0D4-F4D437426627" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Thu, 24 Jun 2021 15:52:26 -0400 In-Reply-To: Cc: PHP internals To: "G. P. B." References: <012901d7683a$446a7ba0$cd3f72e0$@gmail.com> X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] Introduce str_left/right In 8.1 From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_4E5172BD-507F-4103-A0D4-F4D437426627 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Jun 24, 2021, at 8:04 AM, G. P. B. = wrote: >=20 > Moreover, the fact that only a very restricted number of programming > languages, which are some of the earliest languages ever, implement = those > functions should tell you something about programming language design > as a whole, which is that many people came to the conclusion that a = variant > of substring is a better abstraction than "left/right". It think the distinction is not so much that is earlier vs. later = languages, but who the target market is for the languages. For languages = that offer left() and right() function the average developer skill for = developers proficient in those language tends to be lower than for = languages that do not have those functions, compared on a absolute scale = to the most highly-skilled professional developers, of course. Erlang has left() and right() string methods, and it is not an earlier = language. R is not an early language and it has StrLeft() and StrRight() but R is = a language targeting data scientists instead of hard core programmers. Visual Basic is not earlier, but it is based on early Basic. That said = it has always targeted more line-of-business programmers than = professional programmers. Excel, which is an end-users tool has LEFT() and RIGHT() functions. =20 Wikipedia actual has a really nice comparison of languages on string = handling: - = https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_= functions)#left = - = https://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_= functions)#right = =20 So a question to ask about PHP we could collectively answer is: Who is = the target market for PHP? =20 If we collectively want to forsake lower-skilled developers then no, it = would not make sense to include str_left()/str_right() because few = programming languages targeting more advanced developers do. OTOH if we do want to maintain approachability for lower-skilled = developers and allow them easier success experiences then adding = functions like str_left()/str_right() make a lot of sense. Maybe it would make sense to have the community identify and define who = PHP's target user is, and then put that as a stake in the ground? If = that were agreed and explicitly stated on PHP.net for = reference, it sure could help stop a lot of bikeshedding and heated = debates among people with different visions for the future of PHP. =20 #justsaying =20 ---- That said, many newer languages use the indexing operator to extract = substrings of length 2 or more, which PHP does not. =20 Given your comment about early languages are you amenable to adding a = substring indexing syntax to PHP for strings and arrays? I quite like how Swift does it, but there are many others: - Swift: https://stackoverflow.com/a/39677331/102699 = =20 - Go: https://www.dotnetperls.com/substring-go = - Python: = https://runestone.academy/runestone/books/published/thinkcspy/Strings/Inde= xOperatorWorkingwiththeCharactersofaString.html = =20 - Ruby: https://stackoverflow.com/a/4528091/102699 = - F#: https://dotnetcodr.com/2017/02/18/creating-substrings-in-f/ = =20 - D: https://stackoverflow.com/a/20570677/102699 = =20 - Mathematica: = https://reference.wolfram.com/language/ref/StringTake.html = =20 -Mike --Apple-Mail=_4E5172BD-507F-4103-A0D4-F4D437426627--