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

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

Re: Calling different kinds of functions, which finish the same job


From: Kevin Rodgers
Subject: Re: Calling different kinds of functions, which finish the same job
Date: Tue, 11 Apr 2006 09:49:29 -0600
User-agent: Mozilla Thunderbird 0.9 (X11/20041105)

[This doesn't belong on emacs-devel]

Herbert Euler wrote:
> 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.

What are "args of f1" etc?  They are apparently not the arguments to a
single call to f1, since you have these variations:

(apply ,func) ; this is tried first
(apply ,func (car ,largs)) ; then this is tried, while cdr'ing down largs

If all of the functions are defined, why would any of the function call
signal an error?  Why do you care which function is actually called?
You certainly don't return that information, you only return the result
of the first non-error-signalling call.

--
Kevin Rodgers





reply via email to

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