unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Can we add two args to copy-sequence?
@ 2017-12-15  3:32 jun
  2017-12-15  7:54 ` John Wiegley
  0 siblings, 1 reply; 5+ messages in thread
From: jun @ 2017-12-15  3:32 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 112 bytes --]

like this: (copy-sequence seq &optional from to).  'from' and 'to' mean the same as in the function 'substring'.

[-- Attachment #2: Type: text/html, Size: 270 bytes --]

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

* Re: Can we add two args to copy-sequence?
  2017-12-15  3:32 Can we add two args to copy-sequence? jun
@ 2017-12-15  7:54 ` John Wiegley
  2017-12-15  8:24   ` Elias Mårtenson
  0 siblings, 1 reply; 5+ messages in thread
From: John Wiegley @ 2017-12-15  7:54 UTC (permalink / raw)
  To: jun; +Cc: emacs-devel

>>>>> "j" == jun  <netjune@163.com> writes:

j> like this: (copy-sequence seq &optional from to). 'from' and 'to' mean the
j> same as in the function 'substring'.

I'd rather not overload copy-sequence that way, and rather have a new function
named (sublist LIST &optional FROM TO), even if copy-sequence xs == sublist xs.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2



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

* Re: Can we add two args to copy-sequence?
  2017-12-15  7:54 ` John Wiegley
@ 2017-12-15  8:24   ` Elias Mårtenson
  2017-12-15 14:52     ` jun
  0 siblings, 1 reply; 5+ messages in thread
From: Elias Mårtenson @ 2017-12-15  8:24 UTC (permalink / raw)
  To: jun, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On 15 December 2017 at 15:54, John Wiegley <johnw@gnu.org> wrote:

> >>>>> "j" == jun  <netjune@163.com> writes:
>
> j> like this: (copy-sequence seq &optional from to). 'from' and 'to' mean
> the
> j> same as in the function 'substring'.
>
> I'd rather not overload copy-sequence that way, and rather have a new
> function
> named (sublist LIST &optional FROM TO), even if copy-sequence xs ==
> sublist xs.
>

There is already the function ‘subseq’ that does exactly this, or did I
misunderstand
the question?

[-- Attachment #2: Type: text/html, Size: 935 bytes --]

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

* Re:Re: Can we add two args to copy-sequence?
  2017-12-15  8:24   ` Elias Mårtenson
@ 2017-12-15 14:52     ` jun
  2017-12-16  6:18       ` John Wiegley
  0 siblings, 1 reply; 5+ messages in thread
From: jun @ 2017-12-15 14:52 UTC (permalink / raw)
  To: Elias Mårtenson; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

Yes, I just know subseq. And there are also seq-subseq, seq-take, seq-drop, butlast, Two many and hard to remmber.
Almost all of them are implemented in lisp except copy-sequence which is in C. Some of them are implemented
by copying the whole sequence and then modify the copy. If we add the two args to copy-sequence, 
then  these functions can be based on it with only one or two lines in lisp, and reduce some data copy.
Does the two args make copy-sequence too much complex internally?




在 2017-12-15 16:24:50,"Elias Mårtenson" <lokedhs@gmail.com> 写道:

On 15 December 2017 at 15:54, John Wiegley <johnw@gnu.org> wrote:
>>>>> "j" == jun  <netjune@163.com> writes:

j> like this: (copy-sequence seq &optional from to). 'from' and 'to' mean the
j> same as in the function 'substring'.

I'd rather not overload copy-sequence that way, and rather have a new function
named (sublist LIST &optional FROM TO), even if copy-sequence xs == sublist xs.



There is already the function ‘subseq’ that does exactly this, or did I misunderstand
the question?

[-- Attachment #2: Type: text/html, Size: 1879 bytes --]

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

* Re: Can we add two args to copy-sequence?
  2017-12-15 14:52     ` jun
@ 2017-12-16  6:18       ` John Wiegley
  0 siblings, 0 replies; 5+ messages in thread
From: John Wiegley @ 2017-12-16  6:18 UTC (permalink / raw)
  To: jun; +Cc: Elias Mårtenson, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1395 bytes --]

>>>>> "j" == jun <netjune@163.com> writes:

j> Yes, I just know subseq. And there are also seq-subseq, seq-take, seq-drop,
j> butlast, Two many and hard to remmber. Almost all of them are implemented
j> in lisp except copy-sequence which is in C. Some of them are implemented by
j> copying the whole sequence and then modify the copy. If we add the two args
j> to copy-sequence, then these functions can be based on it with only one or
j> two lines in lisp, and reduce some data copy. Does the two args make
j> copy-sequence too much complex internally?

Ah, subseq, there it is. I kept looking for sublist or some variant thereof.

It's not that it's too complex internally, it's that extracting a sublist is
not the purpose of copy-sequence. You are asking us to add extra arguments to
a function to double its purpose, in a way that's more than just "copying a
sequence", as the name implies.

I'm very much against shoe-horning other behaviors into functions that appear
"close enough" for this sort of convenience. Please use cl-subseq. If we need
to move subseq into C, that's a different request, and could be made on
grounds of efficiency or speed. But I won't make copy-sequence more complex
for this reason.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]

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

end of thread, other threads:[~2017-12-16  6:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-15  3:32 Can we add two args to copy-sequence? jun
2017-12-15  7:54 ` John Wiegley
2017-12-15  8:24   ` Elias Mårtenson
2017-12-15 14:52     ` jun
2017-12-16  6:18       ` John Wiegley

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