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

* Re: Should `position' be implemented in Emacs core and preloaded?
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-10-05 15:13 UTC (permalink / raw)
  To: emacs-devel

> 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'.

I consider seq.el as "core" already.  Actually, I also consider
cl-lib as "core".  The fact that you have to rite (require <..>) is
fairly secondary.

I think sooner or later, these libraries will be preloaded (not sure
which of the two will get there first, tho).

Also, FWIW, I don't see many uses of these cl/seq-position functions
in Emacs, so I'm not sure how important they are, really.


        Stefan




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

* Re: Should `position' be implemented in Emacs core and preloaded?
  2016-10-05 15:13 ` Stefan Monnier
@ 2016-10-05 15:37   ` Tino Calancha
  2016-10-05 15:50     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Tino Calancha @ 2016-10-05 15:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers



On Wed, 5 Oct 2016, Stefan Monnier wrote:

>> 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'.
>
> I consider seq.el as "core" already.  Actually, I also consider
> cl-lib as "core".  The fact that you have to rite (require <..>) is
> fairly secondary.
Yes, you are right.  Of course, they are core Emacs.
What i meant is that it would be nice if people could use that 
kind of useful functions without face resistances.  I saw before
in this list people who wanted to use a function from cl-lib or seq.el,
and they received objections because that would force that file to
require such lib.

> I think sooner or later, these libraries will be preloaded (not sure
> which of the two will get there first, tho).
That sounds interesting.
> Also, FWIW, I don't see many uses of these cl/seq-position functions
> in Emacs, so I'm not sure how important they are, really.
I suspect that one important reason to not appear widely is exactly
that in order to use them we need to require the lib to use it.  Probably
if `member' would be just an alias to `cl-member', we wouldn't see it
as many times as we can see it now in Emacs tree.  I bet that if we follow
the I) above, we will start to see many uses of those functions in the new
code.



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

* Re: Should `position' be implemented in Emacs core and preloaded?
  2016-10-05 15:37   ` Tino Calancha
@ 2016-10-05 15:50     ` Stefan Monnier
  2016-10-05 16:14       ` Tino Calancha
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-10-05 15:50 UTC (permalink / raw)
  To: emacs-devel

> What i meant is that it would be nice if people could use that kind of
> useful functions without face resistances.  I saw before
> in this list people who wanted to use a function from cl-lib or seq.el,
> and they received objections because that would force that file to
> require such lib.

Normally such resistance only appears when it would require preloading
seq or cl-lib (i.e. when it's used by a file which is itself preloaded).

I think preloading seq.el would be OK under the following conditions:
- seq.el is changed so as not to require cl-lib (that's mostly
  a question of moving shared code between the two libs so that it's in
  seq.el instead of in cl-lib, so it shouldn't be too difficult).
- one of the preloaded files really benefits from seq.el.

>> Also, FWIW, I don't see many uses of these cl/seq-position functions
>> in Emacs, so I'm not sure how important they are, really.
> I suspect that one important reason to not appear widely is exactly
> that in order to use them we need to require the lib to use it.

You might be right.  I guess there's also the fact that on singly-linked
lists, using seq-position is rarely the best way (in terms of
efficiency) to get the job done.


        Stefan




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

* Re: Should `position' be implemented in Emacs core and preloaded?
  2016-10-05 15:50     ` Stefan Monnier
@ 2016-10-05 16:14       ` Tino Calancha
  0 siblings, 0 replies; 5+ messages in thread
From: Tino Calancha @ 2016-10-05 16:14 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel



On Wed, 5 Oct 2016, Stefan Monnier wrote:

>> What i meant is that it would be nice if people could use that kind of
>> useful functions without face resistances.  I saw before
>> in this list people who wanted to use a function from cl-lib or seq.el,
>> and they received objections because that would force that file to
>> require such lib.
>
> Normally such resistance only appears when it would require preloading
> seq or cl-lib (i.e. when it's used by a file which is itself preloaded).
>
> I think preloading seq.el would be OK under the following conditions:
> - seq.el is changed so as not to require cl-lib (that's mostly
>  a question of moving shared code between the two libs so that it's in
>  seq.el instead of in cl-lib, so it shouldn't be too difficult).
> - one of the preloaded files really benefits from seq.el.
I support this idea; seq.el is light and efficient so let's use it more.





^ 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).