unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Calling different kinds of functions, which finish the same job
@ 2006-04-11  8:12 Herbert Euler
  0 siblings, 0 replies; only message in thread
From: Herbert Euler @ 2006-04-11  8:12 UTC (permalink / raw)


Hello,

Assume there are some functions, for instance, f1, f2, f3,
all of them are doing the same job, but with different arguments.
If I want to call one of them, but don't know which one is
actually called, how can I do that?  I've written two macros
like

(defmacro xgp-casi2-safe-call-iter (func largs)
  `(if ,largs
       (condition-case nil
           (apply ,func (car ,largs))
         (error (xgp-casi2-safe-call-iter ,func (cdr ,largs))))))

(defmacro xgp-casi2-safe-call (func largs)
  "Call function FUNC, try each element of LARGS, which is a list of list, 
as argument to FUNC.
First call without arguments."
  `(condition-case nil
       (apply ,func)
     (error (xgp-casi2-safe-call-iter ,func ,largs))))

And I will call it with

    (xgp-casi2-safe-call function '((args of f1) (args of f2) (args of f3)))

This is my solution.  Any suggestions?  Thanks in advance.

Regards,
Guanpeng Xu

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-11  8:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-11  8:12 Calling different kinds of functions, which finish the same job Herbert Euler

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