Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125813 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id BC03C1A00BD for ; Sun, 20 Oct 2024 20:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1729456334; bh=OA76fLm7dTM+FmgF9KE9bOf2pMzx8ZBNp3OOV9SbTBo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XCTpZYj7j6er7YVB+zkMRbKMIpH1ix+nwoc1YWIpZM+nO0QbpD8ddw7ToQv4lQFe3 ZtPRV/Hc0j+TBjl2J7xARsnij7V6ofeC6fevx5rGZn8df+pB9VArXDsVMSHCSOpuMV DRPrSuGovJMFxmDpbxkmNP75taO5C4Ru934cp+qdO5m4mCs1juvEZBLBnSFonZlfo9 tpPJSYbROjFYnmWLiukKdOAx0/8ndEqIsskgGY/qSgbY9Pn6HJOIlMpBP+dT8Fdnt0 FUElKIwnQ8hzaKKohPgNNbPdU6fjye9la4jCG1zrfxVYjJGzUxtdcbUoHBoJ9yRRp7 usbdqfO74yoFA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0E3AE18003F for ; Sun, 20 Oct 2024 20:32:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 20 Oct 2024 20:32:13 +0000 (UTC) Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-e28fd8cdfb8so3368383276.3 for ; Sun, 20 Oct 2024 13:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scriptfusion-com.20230601.gappssmtp.com; s=20230601; t=1729456189; x=1730060989; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BcgLBuvBBUcdTGC1lhy/mLDcpGCvxMiFcxQSFzpzuo4=; b=nHpt25vbFYUN4MW1rd7uKicLKxA2pdDZk8GHHzR0sF7Gn/P/fqCHMFypYEAwT2ces5 P6F/o/YUsnBFupDOsr1bSLUPJ9UcM4ecy+5Ju9pWSDqWhyN8WoSEK8SZKvJ3aSCRInB2 TUYjsRZsOPQ0NKB7ikOomCOj1KYNjxl5ZC8pdBJVzbhWve6GfiV52bDXYWiM+0ds11xW WS2AnNqba3/RFqzsuuPtL/vGUXDCf3L/pxxxj96MvhM2+/alr+cEl5eApmAUC6jhZBxF WjQUzg5K+l1g1XyFhtIoOcb0qgENPDSgB+ox8REWq8HxhSy5JkN+ICQNJ3ebeLRswDvL pcAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729456189; x=1730060989; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BcgLBuvBBUcdTGC1lhy/mLDcpGCvxMiFcxQSFzpzuo4=; b=sd17cC023JLIYhxJswo7QIeXPTs57aGY5YaC/t0ELSSG5duwBeA74PoMrh5S9qokUr caPWlg4ORPhw6D+IIrBu54JmqJW5TovZtBy4KWGWZijOqxojQfIqz4VGTw7rKXgie7g/ NWUs3om8mZimQW8ujLiRxl3ZnezbzB9936qp4Lne0clMtdPfTlgIyMhfmXP05SguPG6s k0q5KgY4Q7/YoTI95xSHTQqpKiw5HNYohBLmt2d0duz8/DUCaVLcNw9Ttn09cyQrwy5I t3hsRJy5FIZW5sjOyrFmHvMis3I4DmG9Z9TcviRmBBC/5ojC8jeMQZlbKRHKeRCIELtb nxXA== X-Gm-Message-State: AOJu0YyRCgspJKqT13e/6qazIBXWn+Hyhu3Zb4Ctm1hTUql7a7ooktrS fgei6EL5jqBH+ME5mUHZyG4gcUzyZ00l3tztRDaglaeMp2UXhgaZ6iQ471SNz32ay56qaZNsvy9 tfpaQbSSnOOAgXL9JMOdeTedZ9DPTdQDbZmyfjjP6rcWgDrvN X-Google-Smtp-Source: AGHT+IFRvKrhcHqh/V8ShSp+EQgkPqRuH4mk71j0U79T+0/a+XUrN/VtdRaGrf8nzsfcdrJqJe8thvXuAAzw6RuZ5eo= X-Received: by 2002:a05:6902:2404:b0:e2b:add4:ccd with SMTP id 3f1490d57ef6-e2bb14410eamr7001753276.25.1729456189505; Sun, 20 Oct 2024 13:29:49 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <20340e0e-ddd0-44cd-b555-1402857eb20f@app.fastmail.com> In-Reply-To: <20340e0e-ddd0-44cd-b555-1402857eb20f@app.fastmail.com> Date: Sun, 20 Oct 2024 21:29:38 +0100 Message-ID: Subject: Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000d49a7c0624ee6528" From: bilge@scriptfusion.com (Bilge) --000000000000d49a7c0624ee6528 Content-Type: text/plain; charset="UTF-8" On Sun, 20 Oct 2024, 21:24 Larry Garfield, wrote: > On Sun, Oct 20, 2024, at 12:42 PM, Gina P. Banyard wrote: > > Hello internals, > > > > I would like to propose a short RFC to make the return value of the > > sort() and similar functions more useful: > > https://wiki.php.net/rfc/array-sort-return-array > > > > I intend for the discussion to last 2 weeks and then open the vote. > > > > Best regards, > > > > Gina P. Banyard > > Like others, I'm skeptical of the behavior here not being all that clear. > > What several other languages do, and what I have in the plan for > collections if/when they ever happen, is sort() sorts in place, while > sorted() returns a new value. There's similarly reverse() (in place) and > reversed() (new value returned). > > *sorted($arr) seems like it would be a lot less confusing, and consistent > with what other languages (and hopefully future PHP) do. (I don't know > what that means for array_walk(), but I don't know what that would even > return anyway.) > > --Larry Garfield > I fail to see the logic of present tense = mutate, past tense = copy. At least there is a pattern to it, but I would have to look it up several times before it sunk in since it is not intuitive at all. Cheers, Bilge > --000000000000d49a7c0624ee6528 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sun, 20 Oct 2024, 21:24 Larry Garfield, <larry@garfieldtech.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">On Sun, Oct 20, 2024, at 12:42 PM, Gina P. Ba= nyard wrote:
> Hello internals,
>
> I would like to propose a short RFC to make the return value of the > sort() and similar functions more useful:
> https://wiki.php.net/rfc/array-sort-= return-array
>
> I intend for the discussion to last 2 weeks and then open the vote. >
> Best regards,
>
> Gina P. Banyard

Like others, I'm skeptical of the behavior here not being all that clea= r.

What several other languages do, and what I have in the plan for collection= s if/when they ever happen, is sort() sorts in place, while sorted() return= s a new value.=C2=A0 There's similarly reverse() (in place) and reverse= d() (new value returned).=C2=A0

*sorted($arr) seems like it would be a lot less confusing, and consistent w= ith what other languages (and hopefully future PHP) do.=C2=A0 (I don't = know what that means for array_walk(), but I don't know what that would= even return anyway.)

--Larry Garfield

I fail to see the logic of present tense =3D mutate, past t= ense =3D copy. At least there is a pattern to it, but I would have to look = it up several times before it sunk in since it is not intuitive at all.

Cheers,=C2=A0
Bilge=C2=A0
--000000000000d49a7c0624ee6528--