Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125811 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 E0CC91A00BD for ; Sun, 20 Oct 2024 18:06:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1729447756; bh=ootg+4Q7xr598yNRkNYoPNpIAuAzEp7E0qc1OCSKtxM=; h=References:In-Reply-To:From:Date:Subject:To:From; b=lmj324fQMPx1xcjHjJjDyPq8FQHxbQiov5WXRe8FWxSDkTU/caP6G5AaaEapRRts6 BStbnMnOgt5ClFR3xyTYXehFhmUpR9NfuCKGuwUIGpW82X784ayoboLqY92mpPFH/s C8rNQOx0lFTPTFnKjND4gJDOYTDoziRivo+YK8gguhW2SdH2AD5qfjrAdOBsVkLYmX AZvCFO4G1IeSuWp9ljZmS0YfSNx3wcOkyxccN1jIV7ODjmE8NWYjAkvcIWuEy3snOb gUEkAHd4iwFtLsv+HN6O1LYNfB99S9gqqpN3oPkdJoOBRmXGU7jnCi4YXOrEKMoe0g uLuIr1JASqSaw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 455FA180077 for ; Sun, 20 Oct 2024 18:09:16 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, 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-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 18:09:15 +0000 (UTC) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7ac83a98e5eso303779185a.0 for ; Sun, 20 Oct 2024 11:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729447612; x=1730052412; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ootg+4Q7xr598yNRkNYoPNpIAuAzEp7E0qc1OCSKtxM=; b=RmT3lWQJBKHRL08+xvDX+GUfZZvziu/ZsfZlAtUH7L0EbZK78+RYN8PwFhWoTx/rsw 9sZge/eougjnqsxJWLk1klyi8mPI2sU0uvyElV4MHL0pJ68Dlv8Wp5zSbnRmCFHbAsOd 3yKWVVY+efJltL8gsmoGLrI1n+sQr+AgMQAJnfij372CUtzhE4P4WPpwagi3OJDDSpfE 6gLB5sFzaz4fr5BW7VMRdHoRjcPHKluWD4/9si60XnuqdNEaPMLxuRF4bBqq9n4gEeVd DtEOZFUlS7xEOk1Kb/ucNgK+A1lpEUxJZpHkjtGde794bmdZNqhfnfvBRIaFlB8LAFjj slGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729447612; x=1730052412; h=content-transfer-encoding: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=ootg+4Q7xr598yNRkNYoPNpIAuAzEp7E0qc1OCSKtxM=; b=DCegGTDp8Inj0vZPt98Uq54KRyw9L2B5AoilHQTHkCexSaFKdtGD4MNfhCcJbUfbGH axqeOE5WTOCE5fGT1nLVflF8qG0appAqqFKxgA8Dc7UG4R8BapHAhmQoiqG2BQj0Ci6d sC6X19TxAurMFjbOjgTABGUwOWCJnOb6JVgfqhF4XyBTsCu+FzF4LnlEqp43tnpc4bB4 Owm/cBzF0KZVTYukpIkfmpR76664uaRFkW+/fE8Gthb7JQ+vvJkzadBnXyghmKbri2lS OLQRTqv5ykkPQQ7WXQdKJE5WTtq5DQOrAk+/5gRdXwwpKk0DMsClXsM4AGO6cDz5gq/7 rX/A== X-Gm-Message-State: AOJu0YxAXItjJMasZXzsi2BfH/qt/YEUVuu7eRwo1INSBCJtaMpss/Ab M7IF706hPJr/Q3SMu+gkJZ/++A2/3kd8YLOED6CDuMPV7b8W5hgnbXv9T8/qKo2ABylPNtMj8UA ooBbEagNgYPd7HN030gueyv7Tq7QKRr8QYoY= X-Google-Smtp-Source: AGHT+IEwb9gJUNRPxcRCpHNd1MnDsseOpd7uQQ/G70UiEUeK5rWT7xshbIkUZ0unniS+C/bMbOF8FiPDDcq9ZT6aI24= X-Received: by 2002:a05:620a:44c7:b0:7b1:4783:aa2 with SMTP id af79cd13be357-7b157645e80mr1899188585a.7.1729447611695; Sun, 20 Oct 2024 11:06:51 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Sun, 20 Oct 2024 20:06:41 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] Change behaviour of array sort functions to return a copy of the sorted array To: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Gina On Sun, Oct 20, 2024 at 7:43=E2=80=AFPM Gina P. Banyard = wrote: > > 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 think this adds two unnecessary sources of confusion: 1. What Rob already mentioned: Users may look at the signature and see that an array is returned, and assume the argument won't get modified. 2. Is the array returned by value or by reference? I.e. $a =3D [...]; $b =3D &sort($a); $b[] =3D 'foo'; // Does $a get modified? You're mentioning that: > This behaviour is annoying as it makes writing code in a functional way m= ore cumbersome and tedious. It would help if there were some examples. In any case, I don't think by-ref functions are particularly "functional" anyway. Ilija