From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Newsgroups: gmane.emacs.devel Subject: Re: What's missing in ELisp that makes people want to use cl-lib? Date: Tue, 31 Oct 2023 10:38:09 +0000 Message-ID: References: <46ab3c7d-d820-4bb4-8ec4-97c614d7c8a0@alphapapa.net> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23576"; mail-complaints-to="usenet@ciao.gmane.io" Cc: rms@gnu.org, emacs-devel@gnu.org, stefankangas@gmail.com To: Adam Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 31 11:39:11 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qxm9N-0005tT-M6 for ged-emacs-devel@m.gmane-mx.org; Tue, 31 Oct 2023 11:39:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxm8g-0006BQ-KK; Tue, 31 Oct 2023 06:38:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxm8f-0006B4-B1 for emacs-devel@gnu.org; Tue, 31 Oct 2023 06:38:25 -0400 Original-Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxm8d-0007ll-Pq; Tue, 31 Oct 2023 06:38:25 -0400 Original-Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-507e85ebf50so7661799e87.1; Tue, 31 Oct 2023 03:38:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698748701; x=1699353501; darn=gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7InbCJcKj3fl0BGii7s3w90f+Om3tv57L/m7t0YH8CA=; b=K0ooUWkClAiNn5BRh0WwFb5CbiraCFfOCgn3NqvmQAUrJFit62BAGvVjmXS1Gwnk8W QXTgMpAfBIlHiYrq9kuajBSPB9zybGLp0poIXrdr5lc5HDExGi7qRFH+o3bQqHJtPjcQ zY6iyuRMu9C91h2oe2M6O94jk55Zpk3Zr/Bv/x9amIRNfUxOObIzJaF9SG8FN+Xlm8Cu 0979F6w9TxGZalfsmMYdV/gF4p1vOimopskTozhJHhIYIe0i6wX0KBjJVvKGkkxq13DH pE/+oSIuyN+bxvO8v6XhcILhSLibf2CIdCQblGjMo07PQvycRzQCfRXSruQh/KTMs2t1 pY2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698748701; x=1699353501; h=content-transfer-encoding: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=7InbCJcKj3fl0BGii7s3w90f+Om3tv57L/m7t0YH8CA=; b=sJB/xn1a7NMAXsU0WB3pfPSl4S3vGqG82s6VW6X+XfC+ouWFgN7UJvNDZShTNJQ3vI 1zYAEsnV0ZAschFAVGW4wTkX49cuHn/2zbOMSWWtS7XJtPJA0/9RYV7fm2fFNzfTZ7Df uRGdOpCNw2qEgtna7v2jqwO/AFEISFkfjILUaWHvqk+cad9uAhgOxmIhSkNe/6zNBV59 HDwWtwCgScDklZMH/LaWybVfO0LTju0zGgDfWB4X70RHlTWJHTMt3pgyV6LwTNhgEvLc jwaDYiEAQrXAKkycRKlgIhBSNQmC9sabOJLr4HSA59x36Om+jr/8vNUqt/UJsv7yzCko 8jnQ== X-Gm-Message-State: AOJu0Yzv9DMVwezBsd5/6RFKYEifbGWId9ePtfdu7FRXheamNeRYb2x4 XhPIT0S6ngWrm/KgluQ3uXhgMPuKcvyNGA07xtM= X-Google-Smtp-Source: AGHT+IHZAftOinc/hsthLENAXfWlQKEmGxIuR8js+31p9LnRUg2Z1ocsXZT26TjsbnKEqgruCifWsfd+Pt+Sqgk2Un4= X-Received: by 2002:ac2:4e65:0:b0:500:7efe:313c with SMTP id y5-20020ac24e65000000b005007efe313cmr8010426lfs.24.1698748700852; Tue, 31 Oct 2023 03:38:20 -0700 (PDT) In-Reply-To: <46ab3c7d-d820-4bb4-8ec4-97c614d7c8a0@alphapapa.net> Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x12d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:312017 Archived-At: On Tue, Oct 31, 2023 at 2:32=E2=80=AFAM Adam Porter wr= ote: > > > Do people really want `cl-pushnew', with its keyword arguments? > > Or would a simple `pushnew' be even more pleasing? > > It might be more aesthetically or ideologically pleasing, but it would > be much less useful. :test is often necessary for using EQUAL (as EQ is > often the wrong function to use); without it, a hypothetical non-CL > PUSHNEW function would often be unusable. And :key makes it easy to use > with, e.g. structs' accessor functions (which are very helpful for > developers as they allow compile-time checking, completion, etc). > > When CL-PUSHNEW is called without keyword arguments, it's as simple as a > hypothetical non-CL PUSHNEW that offered no keyword arguments. The > keyword arguments provide optional flexibility; without them, one would > have to write a much larger, more complex form to do the same things. Of course. The other day I noticed we have a C function called 'car-less-than-car' whose only point is to optimize a super-specific use of 'sort'. Maybe in 1993 we didn't have compiler macros but now we do, so this is the wrong way to go about it. We should just write (cl-sort foo #'< :key #'car) which is much more modular, readable, reusable, and doesn't require the programmer to know of this specific vocabulary. Sure, "but what about the optimization?", I hear you ask. Well if you must have it then just use a compiler macro to have your cake and eat it too. In this case, something like (defun cl-sort-compiler-macro (form &rest args) (if (equal (cdr args) '(#'< :key #'car)) `(cl-sort ,(car args) #'car-less-than-car) form)) and add it to the cl-sort declaration with (declare (compiler-macro 'cl-sort-compiler-macro)) > Finally, if there were an additional, non-CL PUSHNEW function added, I > would think that would be much more confusing to users, especially new > ones, for there to be a difference in behavior between PUSHNEW and > CL-PUSHNEW. Exactly. Please don't do this, we have enough such cases already. Either migrate the fully functional version or don't. Also, it's not too late to add keyword arguments to our 'sort' Jo=C3=A3o