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: Fri, 10 Nov 2023 16:10:36 +0000 Message-ID: References: <8a7362da-3cc4-221c-7b8a-a9918677adff@gutov.dev> 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="12871"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Dmitry Gutov , =?UTF-8?Q?Gerd_M=C3=B6llmann?= , =?UTF-8?B?QmrDtnJuIEJpZGFy?= , emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Nov 10 17:11:54 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 1r1U6s-0003lB-6V for ged-emacs-devel@m.gmane-mx.org; Fri, 10 Nov 2023 17:11:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r1U5v-0001TW-2Q; Fri, 10 Nov 2023 11:10:55 -0500 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 1r1U5s-0001QH-Iw for emacs-devel@gnu.org; Fri, 10 Nov 2023 11:10:52 -0500 Original-Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r1U5q-0003LV-JU for emacs-devel@gnu.org; Fri, 10 Nov 2023 11:10:52 -0500 Original-Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-507a5f2193bso2448868e87.1 for ; Fri, 10 Nov 2023 08:10:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699632649; x=1700237449; 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=bp7Qb6UUvuNUOTQkOf76OOBzaWsIk7PrYeGU9VBYDow=; b=bAYaZzBFrCswf2FCmEIveWmg6CPl4hcHRaY6s71/t3suPJJVtyV9hziLGFMq6zCTyx UHBBHjI8WQFVRWCzvRuKlmptDZaOi1fZoFuafCPgSfE3KmPYWXwIxIjPZIwhYeTYc5Wy Gt8YbdKWxmjIF0ljWrI4Efoosnhw61zTdPcZDz0Xr+NQnfHButsRnTO9bWOntByuddYV r8/of84/OcCUVoZ1i0EgZjrLOi2hLZSIHPO/04kcYUeNL69GjpWFhftU88ZBCplEDJYU KjuIqA4OJzt0gyay6r0WPYmhRmGi32ARLC8K0gzpIPT95NKV2CqabOZySe9yHCnY19ba 466A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699632649; x=1700237449; 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=bp7Qb6UUvuNUOTQkOf76OOBzaWsIk7PrYeGU9VBYDow=; b=DI3VYbfec0A3NHpnbHB5xdkCKmAphNKVC+9BYgpai9HcOwSSdCt6JzDnzaagnaxoSl nHudcVbAou+9j/zroDC43hEgpvH8DeQo5gST6Upes1rU2wmvPzMItPhvy7qIlWUjKnKk wsyQE1T8oJz2c/gea2qj6pLreb9BFsLzJCGvVb0hQ7yOYilvr173uQ4L4e2LyXH6Uq0H gWn27mTIbJX0mOW32t64VA1mlnvQH7TWpVS0wz3Hdh95P/lv1OSlKUpiUZILqxJLy5Lt nePXsQPcPheD4SEhtIOKWIcso33NCfGGqGBwnt985LoEvUS42gqUNP0JGllDF6tOWVIf T0tg== X-Gm-Message-State: AOJu0Yx6df8+SO0PoJ3W7S2Ngv9jtpu2yPGhdOamesfEgvcj2fvodqVe 6mluFfSbGspcPoxAWUSH0AjngvmsP/cnGBF0OOk= X-Google-Smtp-Source: AGHT+IGMrBrRK7YLGKC9UZerEqJuORj+Xx2Meg3tsVLTBZYeHHDOVtu7Rm0B060l2Pna+TvzIxNiuN6ve37gOxQKJpM= X-Received: by 2002:a05:6512:2388:b0:509:1467:5f18 with SMTP id c8-20020a056512238800b0050914675f18mr1384946lfv.5.1699632648574; Fri, 10 Nov 2023 08:10:48 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=joaotavora@gmail.com; helo=mail-lf1-x132.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, T_SCC_BODY_TEXT_LINE=-0.01 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:313508 On Fri, Nov 10, 2023 at 3:47=E2=80=AFPM Alan Mackenzie wrote: > > On Fri, Nov 10, 2023 at 15:14:05 +0000, Jo=C3=A3o T=C3=A1vora wrote: > > On Fri, Nov 10, 2023 at 3:11=E2=80=AFPM Alan Mackenzie wro= te: > > > > > Those are not public functions, Alan. Even Dmitry pointed that out > > > > immediately. > > > > > > The second set were public functions. And as Eli pointed out, > > > non-public functions need documenting too. > > > Oh then I missed that second set in all this jumble. Can you please > > post it again? > > It's in my post in this thread posted at Date: Fri, 10 Nov 2023 12:13:25 > +0000. > > Or to be found at > https://lists.gnu.org/archive/html/emacs-devel/2023-11/msg00439.html. Alright, here are two of the five functions documented in a patch. Will look at the other 3 later. By the way, if you have a web browser, the so-called Common Lisp hyperspec is an excellent resource to learn to work with CL functions. Here is the doc for FILL and REPLACE: http://www.lispworks.com/documentation/HyperSpec/Body/f_fill.htm http://www.lispworks.com/documentation/HyperSpec/Body/f_replac.htm Disclamer: I'm open to tweaking these docstrings I wrote to some reasonable degree, like grammar fixes, reordering sentences, etc. Constructive criticism only. I will not indulge endless hair-splitting, bikeshedding or deep personal considerations of what proper docstrings should contain and look like, especially if I suspect it is fueled by any deep disdain (or "generic aversion" as someone put it) of the cl-lib.el library, such as has been patent so far in some posts of this discussion so far. IOW I agree with you that the current docstrings are subpar, so this is why I volunteered to enhance them, but this is my honest writing and my own considerations of what a good docstring should look like, based on many years experience with Lisp and Emacs, and how it may help a honest user of these functions put them to good use or read code containing them. And now the patch for 2 of the 5 functions you mentioned, Jo=C3=A3o diff --git a/lisp/emacs-lisp/cl-seq.el b/lisp/emacs-lisp/cl-seq.el index ec481121ae6..dd9f37b0a82 100644 --- a/lisp/emacs-lisp/cl-seq.el +++ b/lisp/emacs-lisp/cl-seq.el @@ -162,9 +162,19 @@ cl-reduce ;;;###autoload (defun cl-fill (cl-seq cl-item &rest cl-keys) - "Fill the elements of SEQ with ITEM. -\nKeywords supported: :start :end -\n(fn SEQ ITEM [KEYWORD VALUE]...)" + "Replace elements of SEQ between START and END with ITEM. +SEQ is a Lisp sequence. It is destructively modified and +returned. + +START and END are indexes like in `aref' or `elt'. They +designate the subsequence of SEQ to operate on. If END is nil, +process the sequence to the end. They default to 0 and nil, +respectively, meaning process the whole SEQ. + +START and END are keyword arguments. See info node `(cl) Program +Structure > Argument Lists' for details. + +\n(fn SEQ ITEM &key START END...)" (cl--parsing-keywords ((:start 0) :end) () (if (listp cl-seq) (let ((p (nthcdr cl-start cl-seq)) @@ -182,10 +192,30 @@ cl-fill ;;;###autoload (defun cl-replace (cl-seq1 cl-seq2 &rest cl-keys) - "Replace the elements of SEQ1 with the elements of SEQ2. -SEQ1 is destructively modified, then returned. -\nKeywords supported: :start1 :end1 :start2 :end2 -\n(fn SEQ1 SEQ2 [KEYWORD VALUE]...)" + "Replace the elements of SEQ1 with elements of SEQ2. +SEQ1 and SEQ2 are both Lisp sequences. SEQ1 is destructively +modified and returned. + +START1, END1, START2 and END2 can be indexes like in `aref' or +`elt'. Each pair designates two subsequences of SEQ1 and SEQ2, +respectively, to operate on. If END1 or END2 is nil, consider +the respective sequences to the end. + +Consecutive elements of the subsequence of SEQ1 are replaced by +consecutive elements of the subsequence of SEQ2. + +If the subsequences vary in length, the shorter one determines +how many elements are replaced. Extra elements in either +subsequence are ignored. + +START1 and START2 default to 0, END1 and END2 default to nil, +meaning replace as much of SEQ1 as possible with elements from +SEQ2. + +START1, END1, START2 and END2 are keyword arguments. See info +node `(cl) Program Structure > Argument Lists' for details. + +\n(fn SEQ1 SEQ2 &key START1 END1 START2 END2...)" (cl--parsing-keywords ((:start1 0) :end1 (:start2 0) :end2) () (if (and (eq cl-seq1 cl-seq2) (<=3D cl-start2 cl-start1)) (or (=3D cl-start1 cl-start2)