[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: scm_apply_1() vs. scm_apply()
From: |
Alexei Matveev |
Subject: |
Re: scm_apply_1() vs. scm_apply() |
Date: |
Wed, 14 Nov 2012 16:06:45 +0100 |
On 14 November 2012 14:43, Hans Aberg <address@hidden> wrote:
> On 14 Nov 2012, at 11:31, Alexei Matveev wrote:
>
>> I see interface of scm_apply_1() and scm_apply() are the same
>> and dont get the difference [1].
>
> File libguile/eval.c in the distribution gives:
> /* Apply a function to a list of arguments.
>
> This function is exported to the Scheme level as taking two
> required arguments and a tail argument, as if it were:
> (lambda (proc arg1 . args) ...)
> Thus, if you just have a list of arguments to pass to a procedure,
> pass the list as ARG1, and '() for ARGS. If you have some fixed
> args, pass the first as ARG1, then cons any remaining fixed args
> onto the front of your argument list, and pass that as ARGS. */
>
> Then scm_apply_1() does the first:
> SCM
> scm_apply_1 (SCM proc, SCM arg1, SCM args)
> {
> return scm_apply (proc, scm_cons (arg1, args), SCM_EOL);
> }
Actually all uses of scm_apply() in that file have SCM_EOL as the
last argument. Isnt that redundant?
Or is this just an idiom for functions of "two or more" arguments on
the C-side which is unfamiliar to me? Probably this.
scm_apply (SCM proc, SCM arg1, SCM args)
{
/* Fix things up so that args contains all args. */
if (scm_is_null (args))
args = arg1;
else
args = scm_cons_star (arg1, args);
return ...;
}
with
scm_c_define_gsubr ("apply", 2, 0, 1, scm_apply);
Still that "if" looks broken --- it creates an impression
that arg1 is either a list or a member of the (argument)
list. Somewhow that does not typecheck on a first
glance.
But thanks, I think I'll stick with a strict scm_apply_0()
for Fortran.
Alexei