From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nicolas Petton Newsgroups: gmane.emacs.devel Subject: Re: A few thoughts on seq.el Date: Sun, 31 Jul 2016 19:36:13 +0200 Message-ID: <87bn1d1zhu.fsf@petton.fr> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1469986633 21259 80.91.229.8 (31 Jul 2016 17:37:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 31 Jul 2016 17:37:13 +0000 (UTC) User-Agent: Notmuch/0.21 (https://notmuchmail.org) Emacs/25.1.50.1 (x86_64-unknown-linux-gnu) Cc: tino.calancha@gmail.com, emacs-devel@gnu.org To: Tino Calancha Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 31 19:36:54 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bTufV-0005Tg-RG for ged-emacs-devel@m.gmane.org; Sun, 31 Jul 2016 19:36:53 +0200 Original-Received: from localhost ([::1]:40314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTufS-00076W-2V for ged-emacs-devel@m.gmane.org; Sun, 31 Jul 2016 13:36:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTufK-00076Q-RY for emacs-devel@gnu.org; Sun, 31 Jul 2016 13:36:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bTufG-0000Z1-KB for emacs-devel@gnu.org; Sun, 31 Jul 2016 13:36:41 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:47671) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bTufF-0000YH-Av for emacs-devel@gnu.org; Sun, 31 Jul 2016 13:36:38 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1160520161; Sun, 31 Jul 2016 13:36:28 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute5.internal (MEProxy); Sun, 31 Jul 2016 13:36:28 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=pKXE/N8iowTF6xRF+cq8OKDLxUU=; b=Jz8ol QLKLbpwbdyQVTvEnQ5ZIkhzD3ERHuh/mopWXMgpSL0G9T6lX/gFVfumbBrB7Ok4l Z6RAvq3oHg1RP98XfM5jleEchx6AAjoce/4ZmM1LvHB+PqYmAdEm8RG5GqGlu37O M1Q3I2FOc80igrKzQlX3juWDH4rkO6JkuS9N8c= X-Sasl-enc: HvCHy8ECSpSt5HMnOy2CY/X6dzou+U8KZNsGIAfUk7hI 1469986587 Original-Received: from strawberry (lfbn-1-7726-61.w92-167.abo.wanadoo.fr [92.167.139.61]) by mail.messagingengine.com (Postfix) with ESMTPA id 7AB5CF29F3; Sun, 31 Jul 2016 13:36:27 -0400 (EDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:206272 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Tino Calancha writes: > Dear Nico, Hi Tino, > I realize a delightful minimalist design choice in this lib: > to keep just the minimum set of funtions providing same funcionality. > For instance, seq.el has neither `seq-notevery' nor `seq-notany' > which can be easily obtained as negation of `seq-every-p' and > `seq-some'. Glad you like it! > Another example, instead of defining two functions per each operation > ,as CL does (*) for several functions, > > I) func (seq, elt), one receiving args (SEQ ELT). > II) func-if (pred, seq), other receiving args (PRED SEQ). > > seq.el seems to prefer introducing just the more general funcs in II)=20 > (**). Indeed, with some exceptions (that you already caught). > There are two functions that escape from this logic. > A) seq-position > I suggest to define this function so that it receives args as II), > like other functions in the file. > With the current definition, it is not possible to recover > the useful behaviour in II) (***). I think this is a valid exception to the (pred, seq) signature of seq.el methods. The reason is that it would be counter-intuitive to retrieve the position of an element in a sequence, which is really what `seq-position' is about. However, I could introduce another function that would take a predicate, and `seq-position' could reuse it. But I don't want to get rid of `seq-position' as it exists today, I think it's too useful. > B) seq-contains > Once you add this in the lib, the pair (seq-contains, seq-find) > is analog to CL (find, find-if). This breaks the minimalist design > choice mentioned above. Not exactly. `seq-contains' might actually be a bit misleading. It is in essence a predicate, but it is not named `seq-contains-p' because it returns the element if found. Does that make more sense? > I believe `seq-contains' was introduced for convenience: > it is used elsewhere in seq.el and map.el. It is indeed very convenient (as a predicate-ish function), and I think that seq.el wouldn't be complete without it. That said, renaming it `seq-contains-p' might clear things up, but OTOH the function would lose part of its usefulness. > For consistency with the rest of the file, i would expect > not having defined `seq-contains', though. > > D) If the only dependence on 'cl-lib in seq.el is `cl-subseq', There are all the generic functions as well which are defined in cl-lib. > Would be possible to include a func `seq-replace' > (stolen from `cl-replace') I want to avoid side-effects on sequences as much as possible, so I would vote against it. > That would remove the 'cl-lib dependence, one of the > arguments to not load 'seq at Emacs start up, AFAIK. > Does it have any sense? Unfortunately, cl-lib will always be required for the generic functions. That said, what I would really like is to see `cl-defgeneric' and `cl-defmethod' be renamed and moved to Elisp core, they are so useful and powerful. Cheers, Nico --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: GPGTools - http://gpgtools.org iQEcBAEBCAAGBQJXnjcNAAoJECM1h6R8IHkQWSAH/0SYHEiUV/MlaNJjUIHDoNXG ryOp9wSAWp6Rp8xRcEu9JjFGnTDLGPdT6MUn3/dytcs8OZAzVzCM8aun7hcEfzoN 8F77NHXH/0NwIU1X9G9qfHOU/+cU07t27kO12kcoIv7dDXgV9RaeRd0+4KGahQVw tl4ntsIypvicQujfFLpC2Nel8romM3YkvkmQFrIe5T/k2PMmhxNx1vsAhfhcxPHp ZIIesqYp0dKKkevIT175Rjx5VJjnL9P0tz12ltHbFSzRCBM8lUxiWUX5PkpXjE4J w8uy1ZBxJc0cjyd/uHgJqO1YIFw2T0QTaWpNajgGO1ndGLyyFmdE+nxRp3PUpaU= =rDrp -----END PGP SIGNATURE----- --=-=-=--