unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Should `position' be implemented in Emacs core and preloaded?
@ 2016-10-05 14:46 Tino Calancha
  2016-10-05 15:13 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Tino Calancha @ 2016-10-05 14:46 UTC (permalink / raw)
  To: Emacs developers; +Cc: Tino Calancha


Hello Emacs,

sometimes i wonder why functions as useful as `position'
are an alias for `cl-position' instead of part of the core. I mean,
they could be implemented out of cl-lib and be preloaded.
Maybe for other more specialized functions is reasonable to load
`cl-lib', but IMO not to just use a fundamental function
as `position' is.

The functions i have in mind are: `position', `position-if',
`position-if-not' and `subsetp'.

*) `position': very fundamental operation on a sequence.  It
     deserves to be preloaded.
*) `position-if': i like this function very much, it's powerful.
*) `position-if-not': similar as previous one.
*) `subsetp': Another fundamental operation; it allow to check if
     several elements belong to one sequence in a compact way.
     For instance, compare:

(let ((options '(?a ?b ?v ?c)))
   (when (and (member ?a options)
              (member ?b options)
              (member ?c options))
     (message "All are included")))
=> "All are included"

;; with:

(let ((options '(?a ?b ?v ?c)))
   (when (subsetp '(?a ?b ?c) options)
     (message "All are included")))
=> "All are included"

I) We might implement them in, for instance, subr.el.
    This could break backward compatibility in code using
    the alias in cl.el, though; not in the current Emacs
    source code AFAICT.

II) Alternatively, they could be implemented in a lighter
     lib; i guess the natural candidate is seq.el.
     Note that this lib already has `seq-position'.

III) We might keep everything as it is.

IV) Other options that i couldn't imagine.

I would be glad to read your opinions about this idea.
Thank you very much.
Tino



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-05 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-05 14:46 Should `position' be implemented in Emacs core and preloaded? Tino Calancha
2016-10-05 15:13 ` Stefan Monnier
2016-10-05 15:37   ` Tino Calancha
2016-10-05 15:50     ` Stefan Monnier
2016-10-05 16:14       ` Tino Calancha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).