unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* proposal to make null string handling more emacs-y
@ 2012-04-25  0:24 Steve Yegge
  2012-04-25  4:45 ` Karl Fogel
                   ` (5 more replies)
  0 siblings, 6 replies; 59+ messages in thread
From: Steve Yegge @ 2012-04-25  0:24 UTC (permalink / raw)
  To: emacs-devel

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

I haven't started a big flamewar and made fresh new enemies in what has
to be at least three weeks.  So.  Here goes.

I think we should change all the core string-manipulation functions to deal
gracefully with nil arguments.  Specifically, I want to change the smallest
set of functions that may originate the infamous "wrong-type-argument
(stringp, nil)" error, making them instead treat nil as if it were the
empty string.

By way of justification:

  * it's Lispy.  Yes, most Lisp dialects got strings wrong, but that
shouldn't
    stop us.  Strings are just character sequences, and whether you like it
or
    not, the nil/empty-list equivalence is part of Emacs's soul.  Throwing
an
    error on a nil string is a radical departure from the core philosophy.

  * wrong-type-argument (stringp, nil) is, anecdotally speaking, both the
most
    common error encountered by casual users and the most feared, because
    it's incredibly difficult to debug.  What's so hard about debugging it?
    It prevents Emacs from starting up!  So your debugger, evaluator, etc.
are
    all useless, and you're back to binary-partitioning of your .emacs file
until you
    find the offending code.  Setting debug-on-error works for more
experienced
    users, *when* it works (which, combined with --debug-init is not very
often).
    But even then, emacs stack traces are a poor-man's debugging tool at
best.

  * changing the behavior is unlikely to break much code.  Emacs libraries
should
    already do nil-checking on string arguments.  And nobody should be
relying
    on error conditions for normal control flow, so no code should be
depending
    on the string functions signaling this error.

The second argument is the real reason I've come to believe we're doing it
wrong.
Emacs has amazingly powerful runtime debugging facilities.  When Emacs is
running, it's *_*alive_, and you can help newbies debug problems by sending
them
snippets of code to evaluate on the fly.

If Emacs can't start up, or (worse) it gets into one of those horrid
scenarios where
some hook is throwing an error on almost every command and preventing the
user
from doing anything useful, then you're no longer in Emacs.  You're in
brokenville.
All the advantages and pleasure of Emacs as a dev environment have vanished.

In a way, I am arguing that Emacs is different from most other software, in
that
it is better for Emacs to fail silently and keep running than it is to fail
noisily and
prevent the user from doing any work.  This is not by any means an argument
you'd make about most software.  But over twenty-five years of daily Emacs
use,
I've decided that throwing errors on nil strings -- however good the
intentions may
have been -- is doing more harm than good.

Before you reject the idea out of hand, I'd like to ask that you consider
carefully
what behavior would be most consistent with the rest of Emacs, and would
make
best use of existing debugging and diagnostic facilities.

Compared to lexical scoping, this change is pretty minor. ;-)

-steve

p.s. (string= nil "") would still yield nil, of course.  I'm proposing
that we treat nil
as the empty string, not the other way around.

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

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

end of thread, other threads:[~2012-06-03  3:45 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-25  0:24 proposal to make null string handling more emacs-y Steve Yegge
2012-04-25  4:45 ` Karl Fogel
2012-04-25  6:28 ` Miles Bader
2012-04-25  6:34   ` Miles Bader
2012-04-25 13:21   ` Ted Zlatanov
2012-05-01 22:01     ` Randal L. Schwartz
2012-04-25  7:53 ` Helmut Eller
2012-04-25  8:22 ` Eli Zaretskii
2012-04-25 14:28   ` Stefan Monnier
2012-04-25 14:35     ` Eli Zaretskii
2012-04-25 15:30       ` Stefan Monnier
2012-04-25 16:41         ` Miles Bader
2012-04-25 16:45         ` Andreas Schwab
2012-04-25 16:46         ` Juanma Barranquero
2012-04-26 21:20         ` Steve Yegge
2012-04-26 22:11           ` Miles Bader
2012-04-26 23:52             ` Steve Yegge
2012-04-27  0:29               ` Miles Bader
2012-04-27  3:20                 ` Jeremiah Dodds
2012-04-27  3:41                   ` Miles Bader
2012-04-27  3:59                     ` Jeremiah Dodds
2012-04-27  4:24                       ` Miles Bader
2012-04-27  8:49                         ` Thien-Thi Nguyen
2012-04-27 14:23                         ` Nix
2012-04-28  2:07                         ` Better startup error handling (was: proposal to make null string handling more emacs-y) Stefan Monnier
2012-04-28 12:04                           ` Better startup error handling Nix
2012-04-28 15:16                             ` Stefan Monnier
2012-04-28 15:42                               ` David Engster
2012-04-28 15:55                               ` Drew Adams
2012-04-28 19:39                                 ` Stefan Monnier
2012-04-28 17:26                           ` Lars Magne Ingebrigtsen
2012-04-30  8:43                           ` Christian Lynbech
2012-04-30  9:18                             ` chad
2012-04-27 16:35                   ` proposal to make null string handling more emacs-y Richard Stallman
2012-04-27  1:10           ` Stefan Monnier
2012-04-27  1:16             ` Lars Magne Ingebrigtsen
2012-04-27 16:35               ` Richard Stallman
2012-04-28 11:13                 ` Eli Barzilay
2012-04-28 17:02                   ` Richard Stallman
2012-04-28 19:48                     ` Stefan Monnier
2012-04-28 21:56                     ` Eli Barzilay
2012-06-03  3:45                       ` Richard Stallman
2012-04-27  4:17             ` Steve Yegge
2012-04-27  6:36               ` Eli Zaretskii
2012-04-27 19:05                 ` Steve Yegge
2012-04-27 21:24                   ` Drew Adams
2012-04-28  4:43                     ` Steve Yegge
2012-04-28  6:58                       ` Andreas Schwab
2012-04-29 21:26                   ` Odd formatting (was: proposal to make null string handling more emacs-y) Lars Magne Ingebrigtsen
2012-04-30  7:48                     ` Odd formatting Steinar Bang
2012-04-30 10:14                       ` Antoine Levitt
2012-04-30 13:27                         ` Nix
2012-04-28  2:02               ` proposal to make null string handling more emacs-y Stefan Monnier
2012-04-25 14:51 ` Lars Magne Ingebrigtsen
2012-04-29 17:00 ` Andreas Röhler
2012-04-29 17:08   ` Drew Adams
2012-04-29 17:29     ` Andreas Röhler
2012-04-29 18:01       ` Drew Adams
2012-04-29 19:51       ` PJ Weisberg

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