From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: Calling different kinds of functions, which finish the same job
Date: Tue, 11 Apr 2006 12:36:55 -0600 [thread overview]
Message-ID: <e1gt1k$bk3$1@sea.gmane.org> (raw)
In-Reply-To: <BAY112-F2153B2BA69AF3B9DD91E9FDACD0@phx.gbl>
Herbert Euler wrote:
>> From: Kevin Rodgers <ihs_4664@yahoo.com>
>> To: help-gnu-emacs@gnu.org
>> Subject: Re: Calling different kinds of functions, which finish the
>> same job
>> Date: Tue, 11 Apr 2006 09:49:29 -0600
>>
>> [This doesn't belong on emacs-devel]
>
>
> OK. Sorry for having sent to emacs-devel.
>
>> 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.
>
>
> Suppose functions f1, f2, and f3 are all for inserting one space, but
> without side effect or with different side effect; f1 requires an
> integeral argument as count, f2 requires an symbolic argument specifies
> how the side effect is caused, and f3 requires two arguments, one
> of them is an integer, the other one is a symbol. Now, if I want to
> insert one space (either with or without side effect), I can issue one
> of the following commands:
>
> (f1 1)
> (f2 'indent)
> (f3 1 'indent)
>
> And I'm granteed that, if one space is inserted, one of f1, f2, f3 is
> called, but I don't which one is called. So I want I can write (with
> function in my last post),
>
> (xgp-casi2-safe-call f '((1) (indent) (1 indent)))
>
> Where f is one of f1, f2, or f3 (got from environment).
No you can't, because your macros call
(f1)
(f1 1)
(f2)
(f2 indent)
(f3)
(f3 1)
(f3 indent)
> If f can be
> self-insert-command as well, the first trial will be successful (so
> perhaps I should make invoking without arguments the last trial).
>
> Any better solutions? Thanks.
(condition-case nil
(f1 1)
(error (condition-case nil
(f2 'indent)
(error (f3 1 'indent)))))
(defmacro try (&rest forms)
"Eval FORMS until one of them returns without signalling an error."
`(condition-case nil
,(car forms)
(error (try ,@(cdr forms)))))
(try (f1 1) (f2 'indent) (f3 1 'indent))
--
Kevin Rodgers
next prev parent reply other threads:[~2006-04-11 18:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='e1gt1k$bk3$1@sea.gmane.org' \
--to=ihs_4664@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).