mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
add procedure_minimum_arity
* libguile/procprop.h: * libguile/procprop.c (scm_procedure_minimum_arity): New public function, will replace (procedure-property foo 'arity). * libguile/programs.c (scm_i_program_arity): Rework to always provide the most permissive arity.
This commit is contained in:
parent
1e23b461ec
commit
cb2ce54844
3 changed files with 62 additions and 18 deletions
|
@ -71,6 +71,31 @@ scm_i_procedure_arity (SCM proc, int *req, int *opt, int *rest)
|
|||
return scm_i_program_arity (proc, req, opt, rest);
|
||||
}
|
||||
|
||||
SCM_DEFINE (scm_procedure_minimum_arity, "procedure-minimum-arity", 1, 0, 0,
|
||||
(SCM proc),
|
||||
"Return the \"minimum arity\" of a procedure.\n\n"
|
||||
"If the procedure has only one arity, that arity is returned\n"
|
||||
"as a list of three values: the number of required arguments,\n"
|
||||
"the number of optional arguments, and a boolean indicating\n"
|
||||
"whether or not the procedure takes rest arguments.\n\n"
|
||||
"For a case-lambda procedure, the arity returned is the one\n"
|
||||
"with the lowest minimum number of arguments, and the highest\n"
|
||||
"maximum number of arguments.\n\n"
|
||||
"If it was not possible to determine the arity of the procedure,\n"
|
||||
"@code{#f} is returned.")
|
||||
#define FUNC_NAME s_scm_procedure_minimum_arity
|
||||
{
|
||||
int req, opt, rest;
|
||||
|
||||
if (scm_i_procedure_arity (proc, &req, &opt, &rest))
|
||||
return scm_list_3 (scm_from_int (req),
|
||||
scm_from_int (opt),
|
||||
scm_from_bool (rest));
|
||||
else
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
SCM_DEFINE (scm_procedure_properties, "procedure-properties", 1, 0, 0,
|
||||
(SCM proc),
|
||||
"Return @var{obj}'s property list.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue