help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Handling varying numbers of arguments in different versions


From: Miles Bader
Subject: Re: Handling varying numbers of arguments in different versions
Date: 14 Aug 2002 10:37:05 +0900

Glenn Morris <gmorris+news@ast.cam.ac.uk> writes:
> Thanks for the responses everyone. I've discovered that by going with the
> condition-case approach and then disguising the function call somewhat with
> apply, I can suppress byte-compiler warnings too. This makes me happy...

BTW, it seems rather safer (and more efficient) to do the
`condition-case' test at load time, under controlled circumstances,
rather than inside the wrapper function (what happens if an error is
signalled for other reasons?).

E.g., instead of using

  (defun my-foo (x y)
    (condition-case e (foo x y)
      ((wrong-number-of-arguments) (foo x))))

use

  (if (condition-case e (progn (foo 1 2) t) ((wrong-number-of-arguments) nil))
      (defalias 'my-foo 'foo)
    (defun my-foo (x y) (foo x)))

[perhaps you're alreadying doing this, but it's not clear from the postings]

-miles
-- 
`Cars give people wonderful freedom and increase their opportunities.
 But they also destroy the environment, to an extent so drastic that
 they kill all social life' (from _A Pattern Language_)




reply via email to

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