all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Compatibility aliases, defsubsts, and macros...
@ 2006-01-30 21:59 Bill Wohler
  2006-01-30 23:05 ` Miles Bader
  0 siblings, 1 reply; 6+ messages in thread
From: Bill Wohler @ 2006-01-30 21:59 UTC (permalink / raw)
  Cc: mh-e-devel

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 <wohler@newt.com>  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.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642

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

end of thread, other threads:[~2006-02-03 21:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-30 21:59 Compatibility aliases, defsubsts, and macros Bill Wohler
2006-01-30 23:05 ` Miles Bader
2006-01-30 23:36   ` Bill Wohler
2006-01-31  0:41     ` Miles Bader
2006-01-31  5:50       ` Bill Wohler
2006-02-03 21:03         ` Bill Wohler

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.