unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Calling different kinds of functions, which finish the same job
@ 2006-04-11  8:12 Herbert Euler
  2006-04-11 15:49 ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages 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] 8+ messages in thread
[parent not found: <mailman.318.1144803053.9609.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2006-04-12 15:28 UTC | newest]

Thread overview: 8+ messages (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
2006-04-11 15:49 ` Kevin Rodgers
2006-04-11 17:31   ` Herbert Euler
2006-04-11 17:36     ` Herbert Euler
2006-04-11 18:36     ` Kevin Rodgers
2006-04-12  0:50       ` Herbert Euler
     [not found] <mailman.318.1144803053.9609.help-gnu-emacs@gnu.org>
2006-04-12  3:55 ` Stefan Monnier
2006-04-12 15:28   ` Kevin Rodgers

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