emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

removal of `string-to-sequence'


From: Drew Adams
Subject: removal of `string-to-sequence'
Date: Tue, 2 Oct 2012 21:59:03 -0700

I byte-compile my code in Emacs 20 and use the result in 20 and later releases.
Until now (the Windows binary that I picked up today), that has never been a
problem.

Naturally, old code cannot take advantage of newer features - but that is not
the point here.  We have always said that code byte-compiled from an older
version will work in a newer one.

That's now broken.  Case in point: `string-to-list'.  It has always been a
defsubst, apparently.  But its defsubst definition changed in Emacs 22.

Its definition before Emacs 22 was (string-to-sequence string 'list).  In Emacs
22 you deprecated `string-to-sequence', and `string-to-list' became just (append
string nil).  That change, in itself, is not a problem.

`string-to-sequence' continued to exist, so there was no problem with old
byte-compiled code.  Now it's gone, however, so the code breaks.  You removed
the defsubst target for code compiled prior to Emacs 22.  That's not good.

What this means is that for byte-compiled code to work in both Emacs 20/21 and
later versions, users can no longer use `string-to-list'.  They must change
their code to use (append STRING ()).  (Or write their own
function/macro/defsubst.)

Likewise, for `string-to-vector' - they must now use (vconcat STRING).

This is not progress.  It would not hurt Emacs to keep `string-to-sequence', so
that old byte-code continues to be respected.  You need not document it or
advertize it, but you should keep it.

As a general rule, you should not remove code that is used by defsubsts.  (And
as another general rule, it's good to avoid using defsubsts.)

Someone long ago thought that making defsubsts for `string-to-list' and
`string-to-vector' was a good idea.  (And Emacs still does that.)  And they
thought that the generic function `string-to-sequence' was a good idea too.

Someone later decided they were wrong about that second idea.  I say, "Tough
luck."  You should suck it up, take responsibility for that bad past decision,
and keep `string-to-sequence' for forward-compatibility from older releases.
Emacs is full of hysterical raisins.  This one wouldn't hurt anyone.

There are lessons to be learned in this history.  One of them is not to be so
quick to clear out the attic, tossing stuff that you think no one is using.  It
is probably the case that no one is using `string-to-sequence', but you have to
look beyond that.

And please consider also being clear in NEWS about such a code-breaking change.
What you say now is not enough:

** Some obsolete functions, variables, and faces were removed:
*** `string-to-sequence' (use `string-to-list' or `string-to-vector').

The problem is not what to replace `string-to-sequence' with.  I doubt that
anyone even uses `string-to-sequence'.  But lots of people use the defsubst
`string-to-list' or `string-to-vector', and in older versions those expand at
byte-compile time to `string-to-sequence'.

That NEWS entry does not help users of older releases realize how to adapt their
code.

Most users will not even realize that `string-to-list is a defsubst, so they
will not understand why their code is breaking.  They will likely not use
`string-to-sequence' in their code, so that NEWS blurb will appear to be
irrelevant to them.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]