unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Re: Alternative to substring-no-properties
       [not found] ` <200201281536.g0SFaFq21760@aztec.santafe.edu>
@ 2002-03-26 23:19   ` Tak Ota
  2002-03-28  4:55     ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Tak Ota @ 2002-03-26 23:19 UTC (permalink / raw)
  Cc: storm, emacs-devel

Mon, 28 Jan 2002 08:36:15 -0700 (MST): Richard Stallman <rms@gnu.org> wrote:

> It would be cleaner to make it a separate C function
> rather than add a new arg to substring.

I saw the following implementation and it made me wonder why it was
cleaner to have separate C function instead of adding one optional
argument to `substring'.

2002-03-26  Richard M. Stallman  <rms@gnu.org>

	* fns.c (Fsubstring_no_properties): New function.

The implementation of Fsubstring_no_properties is slightly different
from the implementation of Fsubstring since Fsubstring can accept a
vector in place of a string.

Even if the difference was corrected, it is definitely forking the
very similar implementation into two different ones and to maintain
both.

IMHO the following patch Juanma Barranquero provided before looks
much cleaner.

-Tak


Index: fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fns.c,v
retrieving revision 1.303
diff -u -r1.303 fns.c
--- fns.c	13 Nov 2001 11:55:47 -0000	1.303
+++ fns.c	28 Jan 2002 10:26:24 -0000
@@ -1165,15 +1165,16 @@
   return alist;
 }
 
-DEFUN ("substring", Fsubstring, Ssubstring, 2, 3, 0,
+DEFUN ("substring", Fsubstring, Ssubstring, 2, 4, 0,
        doc: /* Return a substring of STRING, starting at index FROM and ending before TO.
 TO may be nil or omitted; then the substring runs to the end of STRING.
 If FROM or TO is negative, it counts from the end.
+Properties are copied unless NO-PROPERTIES is non-nil.
 
 This function allows vectors as well as strings.  */)
-     (string, from, to)
+     (string, from, to, no_properties)
      Lisp_Object string;
-     register Lisp_Object from, to;
+     register Lisp_Object from, to, no_properties;
 {
   Lisp_Object res;
   int size;
@@ -1226,8 +1227,9 @@
       res = make_specified_string (XSTRING (string)->data + from_byte,
 				   to_char - from_char, to_byte - from_byte,
 				   STRING_MULTIBYTE (string));
-      copy_text_properties (make_number (from_char), make_number (to_char),
-			    string, make_number (0), res, Qnil);
+      if (NILP (no_properties))
+        copy_text_properties (make_number (from_char), make_number (to_char),
+                              string, make_number (0), res, Qnil);
     }
   else
     res = Fvector (to_char - from_char,

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Alternative to substring-no-properties
  2002-03-26 23:19   ` Alternative to substring-no-properties Tak Ota
@ 2002-03-28  4:55     ` Richard Stallman
  2002-03-28  5:33       ` Tak Ota
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2002-03-28  4:55 UTC (permalink / raw)
  Cc: storm, emacs-devel

    I saw the following implementation and it made me wonder why it was
    cleaner to have separate C function instead of adding one optional
    argument to `substring'.

I don't know how to say why this is cleaner, but it seems very clear
to me that it is cleaner.

Let's not spend more time on this decision.


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

* Re: Alternative to substring-no-properties
  2002-03-28  4:55     ` Richard Stallman
@ 2002-03-28  5:33       ` Tak Ota
  0 siblings, 0 replies; 3+ messages in thread
From: Tak Ota @ 2002-03-28  5:33 UTC (permalink / raw)
  Cc: storm, emacs-devel

Wed, 27 Mar 2002 21:55:54 -0700 (MST): Richard Stallman <rms@gnu.org> wrote:

> I don't know how to say why this is cleaner, but it seems very clear
> to me that it is cleaner.

I don't agree with you.  You are repeating the subjective opinion to
the objective facts I pointed out.

> Let's not spend more time on this decision.

However, I agree with this part.  I give up.

-Tak

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


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

end of thread, other threads:[~2002-03-28  5:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <5x1ygbia2j.fsf@kfs2.cua.dk>
     [not found] ` <200201281536.g0SFaFq21760@aztec.santafe.edu>
2002-03-26 23:19   ` Alternative to substring-no-properties Tak Ota
2002-03-28  4:55     ` Richard Stallman
2002-03-28  5:33       ` Tak Ota

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