emacs-devel
[Top][All Lists]
Advanced

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

Compatibility aliases, defsubsts, and macros...


From: Bill Wohler
Subject: Compatibility aliases, defsubsts, and macros...
Date: Mon, 30 Jan 2006 13:59:13 -0800

I'm a bit confused by the compatibility alias conventions and was hoping
someone could clarify them for me.

In (elisp)Coding Conventions, I read:

  1. It is a bad idea to define aliases for the Emacs primitives.
     Normally you should use the standard names instead.  The case
     where an alias may be useful is where it facilitates backwards
     compatibility or portability.

  2. If a package needs to define an alias or a new function for
     compatibility with some other version of Emacs, name it with the
     package prefix, not with the raw name with which it occurs in the
     other version.  Here is an example from Gnus, which provides many
     examples of such compatibility issues.

          (defalias 'gnus-point-at-bol
            (if (fboundp 'point-at-bol)
                'point-at-bol
              'line-beginning-position))

Unless I'm missing a subtlety, these two paragraphs seem incompatible
with each other. The following seems OK by #1 but not by #2:

    (unless (fboundp 'assoc-string)
      (defsubst assoc-string (key list case-fold)
        "Like `assoc' but specifically for strings.
    Case is ignored if CASE-FOLD is non-nil.
    This function added by MH-E for Emacs versions that lack
    `assoc-string', introduced in Emacs 22."
        (if case-fold
            (assoc-ignore-case key list)
          (assoc key list))))

This seems preferable to creating a function, macro, or alias
mh-assoc-string which provides no value-add. In the future, when Emacs
22 is the oldest Emacs version supported, we can simply remove the
defsubst and not have to modify the code that calls it. Readers of the
code will be able to quickly read "assoc-string" but will be slowed by
having to check the docstring or code for "mh-assoc-string" to check for
special treatment of our function.

Or perhaps this is OK. Since it does nothing in Emacs 22, it is OK by
point #1. Since it is using the Emacs name rather than the name in an
"other version" of Emacs, it is OK by #2.

-- 
Bill Wohler <address@hidden>  http://www.newt.com/wohler/  GnuPG ID:610BD9AD
Maintainer of comp.mail.mh FAQ and MH-E. Vote Libertarian!
If you're passed on the right, you're in the wrong lane.




reply via email to

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