all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Should undefined behavior be encouraged in Emacs?
@ 2011-10-03  1:39 Paul Eggert
  2011-10-03  3:11 ` Stefan Monnier
                   ` (3 more replies)
  0 siblings, 4 replies; 39+ messages in thread
From: Paul Eggert @ 2011-10-03  1:39 UTC (permalink / raw)
  To: Emacs Development

Bug#9642 has raised a question about Emacs design philosophy.

Some Emacs built-ins treat an out-of-range argument as the nearest
value in range.  For example, (goto-char -5) acts like (goto-char 1),
and (make-overlay -5 1) acts like (make-overlay 1 1), because -5
is out of the range of valid buffer positions.  Other built-ins
signal an exception: for example, (aref "abc" -5) signals an
error, and (forward-char -5) signals an error at buffer start.
And still others wrap around: for example, (- most-negative-fixnum)
yields most-negative-fixnum.

A recent comment in Bug#9642 advocates another approach: undefined
behavior.  For example, it proposes that move-overlay should have
undefined behavior when given arguments like -5 that are out of
range.  In other words, (move-overlay OVERLAY -5 1) might signal
an error, or substitute an in-range value, or wrap around, or
return a data structure that subtly violates some other guarantee
made by Emacs; or it might do one of these things sometimes and
another at other times.  In short, undefined behavior means that
move-overlay might do *anything* when given out-of-range
arguments.

The argument given for undefined behavior is that it simplifies
maintenance of Emacs internals.

My impression is that Emacs built-ins are generally supposed to
have defined behavior, so that Emacs is easier to use reliably.
But another developer apparently disagrees, so thought I'd ask on
emacs-devel for further comments.

Here's the a pointer to the abovementioned comment:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9642#23




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

end of thread, other threads:[~2011-10-08 14:34 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-03  1:39 Should undefined behavior be encouraged in Emacs? Paul Eggert
2011-10-03  3:11 ` Stefan Monnier
2011-10-03  6:39   ` Andreas Röhler
2011-10-03  7:29     ` Stephen J. Turnbull
2011-10-03  8:58       ` Andreas Röhler
2011-10-06  2:17         ` Stephen J. Turnbull
2011-10-06 17:30           ` Richard Stallman
2011-10-06 19:49             ` Stephen J. Turnbull
2011-10-06 20:08               ` Andreas Röhler
2011-10-06 20:12                 ` Lars Magne Ingebrigtsen
2011-10-06 20:46                   ` Eli Zaretskii
2011-10-07  5:23                   ` Andreas Röhler
2011-10-07  7:44                   ` Stephen J. Turnbull
2011-10-07  7:52                     ` John Wiegley
2011-10-07 17:27                       ` Stephen J. Turnbull
2011-10-07  8:38                   ` Alan Mackenzie
2011-10-07 15:26                   ` Barry Warsaw
2011-10-07 18:06                     ` ken manheimer
2011-10-07 18:21                       ` Barry Warsaw
2011-10-07 18:46                       ` Óscar Fuentes
2011-10-07 19:59                         ` ken manheimer
2011-10-07 18:41                     ` Drew Adams
2011-10-08 13:49                   ` Miles Bader
2011-10-08 14:34                     ` Drew Adams
2011-10-03 13:16       ` Stefan Monnier
2011-10-03  9:20   ` Alan Mackenzie
2011-10-03  9:52     ` Eli Zaretskii
2011-10-03  8:29 ` Andreas Schwab
2011-10-03  9:53   ` Eli Zaretskii
2011-10-03 13:13 ` Richard Stallman
2011-10-03 15:15   ` Dave Abrahams
2011-10-04  1:55     ` Richard Stallman
2011-10-04  2:18       ` Dave Abrahams
2011-10-03 16:14   ` Eli Zaretskii
2011-10-03 16:27     ` Andreas Schwab
2011-10-03 16:41       ` Eli Zaretskii
2011-10-04  1:55     ` Richard Stallman
2011-10-03 20:53   ` Paul Eggert
2011-10-03 14:49 ` Dave Abrahams

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.