From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] sequence manipulation functions Date: Tue, 11 Nov 2014 00:12:23 +0100 Message-ID: <87ioimtzu0.fsf@gmail.com> References: <87oasmmwzt.fsf@gmail.com> <87bnolslph.fsf@gmail.com> <87zjc2dic0.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1415661172 18768 80.91.229.3 (10 Nov 2014 23:12:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 10 Nov 2014 23:12:52 +0000 (UTC) Cc: Emacs developers To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 11 00:12:46 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xny8c-0000LR-07 for ged-emacs-devel@m.gmane.org; Tue, 11 Nov 2014 00:12:46 +0100 Original-Received: from localhost ([::1]:45472 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xny8b-0007o8-AC for ged-emacs-devel@m.gmane.org; Mon, 10 Nov 2014 18:12:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xny8T-0007nq-5Y for emacs-devel@gnu.org; Mon, 10 Nov 2014 18:12:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xny8L-0008JG-EF for emacs-devel@gnu.org; Mon, 10 Nov 2014 18:12:37 -0500 Original-Received: from mail-la0-x22e.google.com ([2a00:1450:4010:c03::22e]:42117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xny8L-0008Iu-2X for emacs-devel@gnu.org; Mon, 10 Nov 2014 18:12:29 -0500 Original-Received: by mail-la0-f46.google.com with SMTP id gm9so8456810lab.5 for ; Mon, 10 Nov 2014 15:12:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version:content-type; bh=XJxGwiIRZg52QfjQ++2zIjV7XB0rTKNvSI7o06YA7m0=; b=u736XlZMAXWemEpCM4r6Hb2vQnZ+3WEEpzFZKBuTW9oYLNcbH+LoIv5hY4t8TakSsA YTzz/fHc9Lh9UunBzw+OKIO5wqwDsLo0yN/+j73P/aBO/F4Q+24KToz2RkUdT7LQpURW 3UUKJtDeX6clU6wtNEw9RX2UjJm+EoO9wgt9A6z30we+NH2L4+FedhfmnIeI2l5ClOs3 DbrnOLEsELwv903LcMIsVq0YnmcBf6l8NSJKrV7/tLv8HqgnnO7e9YRXnE7Fo2FR2o7O v0p7Fig5ZRQ2RVTvcmDa1SMmgpoioy16NEZDvyBJXZmM9cL1azKjPnIrAbrptg4dA/th J1NA== X-Received: by 10.152.21.167 with SMTP id w7mr32891524lae.70.1415661147955; Mon, 10 Nov 2014 15:12:27 -0800 (PST) Original-Received: from blueberry (c213-89-134-104.bredband.comhem.se. [213.89.134.104]) by mx.google.com with ESMTPSA id n4sm3841375lan.39.2014.11.10.15.12.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Nov 2014 15:12:27 -0800 (PST) User-agent: mu4e 0.9.9.6pre3; emacs 24.3.1 In-reply-to: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::22e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:176726 Archived-At: Stefan Monnier writes: > >> + (or (listp seq) (setq seq (append seq '()))) >> + (let ((acc (or initial-value (if (seq-empty-p seq) >> + (funcall function) >> + (car seq))))) > > If you want an initial value of nil but your function can only be called > with 2 arguments, you're screwed :-( > Would it be a real problem if we simply made `initial-value' an > mandatory argument? No, I think that's fine. >> + (catch 'seq-some-p-break > > Since this tag is internal, I'd use a "seq--" prefix. I think > `seq--break' should be sufficient. Of course you could also just use > cl-block and cl-return and circumvent the question. Sure, I will use seq--break. >> +(defun seq-sort (seq pred) >> + "Return a sorted list of the elements of SEQ compared using PRED." > > I wonder if that's really the more useful behavior, compared to the > "inplace" sorting of `sort', or compared to the alternative is always > returning a new sequence, but of the same type as the `seq' argument. I can make it return a sequence of the same type as seq. I don't want to sort in place though, all other functions leave seq untouched, and I would like to keep it this way. >> +(defalias 'seq-copy #'copy-sequence) >> +(defalias 'seq-elt #'elt) >> +(defalias 'seq-length #'length) > > I think mapc would make a lot of sense, and I guess mapcar as well. > Not sure if we should name them `seq-mapc' and `seq-mapcar' or > something else. How do "seq-do" and "seq-map" sound like? I'm not confortable with "seq-doseq" or something like that since I would expect it to be a macro similar to "dolist". > >> +(load "emacs-lisp/sequences") > > I think I'd rather not preload it for now and let people use (require > 'seq) for that. There's 30 years of accumulated Elisp code and we're > not going to switch them to use a new naming scheme overnight. It might > even be that people will simply not like to have to add "seq-" in their > code (I know they complained about adding "cl-"), so I'd start by simply > providing the library and when its popularity grows (and/or is being > used by preloaded code) we can then add it to loadup. Fair enough. One question though, if sequences.el is not preloaded, then I guess these functions should not be documented in the manual? But then, how will people find out about it? If nobody knows about it, then it makes it much less likely to be used :) Nico -- Nicolas Petton http://nicolas-petton.fr