summaryrefslogtreecommitdiff
path: root/libguile/procprop.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-04-17 16:03:51 +0200
committerAndy Wingo <wingo@pobox.com>2010-04-17 16:03:51 +0200
commitcb2ce548441824fe1284fc80a3a95394a9fc03d0 (patch)
tree1b64e72c2ae227b03ea1b24a5033f67ba70744fe /libguile/procprop.c
parent1e23b461ecd25c582dd0b10ebb1d7fd22f5e5ec4 (diff)
downloadguile-cb2ce548441824fe1284fc80a3a95394a9fc03d0.tar.gz
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.
Diffstat (limited to 'libguile/procprop.c')
-rw-r--r--libguile/procprop.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libguile/procprop.c b/libguile/procprop.c
index 2b894977a..b7575d199 100644
--- a/libguile/procprop.c
+++ b/libguile/procprop.c
@@ -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.")