[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Calling different kinds of functions, which finish the same job
From: |
Herbert Euler |
Subject: |
Calling different kinds of functions, which finish the same job |
Date: |
Tue, 11 Apr 2006 16:12:56 +0800 |
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
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
- Calling different kinds of functions, which finish the same job,
Herbert Euler <=