- Subject: Re: Re: Template function
- From: Guenter Milde <milde@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 4 Dec 2002 16:44:43 +0100 (CET)
On Wed, 4 Dec 2002 02:16:37 -0500 wrote "John E. Davis" <davis@xxxxxxxxxxxxx>:
> It is important to point out that you should always explicitly pass
> arguments to functions that take a variable number of arguments.
> "sprintf" is one such example. I am surprised that sprintf("%d")
> worked.
It seems like sprintf doesnot use the _NARGS variable but just takes as many
values from the stack as it needs (counting the %'s) ...
Interestingly, also the following works:
define push_array(a)
{
for ($1=0; $1<length(a); $1++)
a[$1];
}
define show_args()
{
$1 = "";
loop(_NARGS)
$1 = string(()) + ", " + $1;
message($1);
}
show_args(push_array([1, 2, "drei"]));
or
show_args(getbuf_info());
but not
push_array(["1", "2", "drei"]);
show_args();
The same problem occures with the
menu_insert_item (position, menu, name, fun [,client_data])
function.
The help text tells:
When called with 5 arguments, the `fun' argument may be either
a string or a reference to a function. When the item is selected,
the function will be called and `client_data' will be passed to it.
Unfortunately, functions that rely on _NARGS do not realize that data is
passed. Also, I'd like to see more than 5 args allowed,i.e. an
implementation similar to runhooks(hook, [args]).
Günter Milde
--
Milde at ife.et.tu-dresden.de
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2002 date index]
[2002 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]