*/
#include "unpure-pure-container.hh"
-// Reroutes a call to the contained function after dropping last two
-// arguments. Used for applying an "unpure" function in a "pure"
+// Reroutes a call to the contained function after dropping second and
+// third argument. Used for applying an "unpure" function in a "pure"
// context.
class Unpure_pure_call : public Smob1<Unpure_pure_call>
{
public:
+ // Smob procedures unfortunately can only take at most 3 SCM
+ // arguments. Otherwise we could use a "3, 0, 1" call signature and
+ // not require an argument count check of our own.
LY_DECLARE_SMOB_PROC (&Unpure_pure_call::call, 2, 0, 1)
- SCM call (SCM arg1, SCM arg2, SCM rest)
+ SCM call (SCM arg1, SCM, SCM rest)
{
- return scm_apply_0 (scm1 (),
- scm_list_head (scm_cons2 (arg1, arg2, rest),
- scm_length (rest)));
+ if (!scm_is_pair (rest))
+ scm_wrong_num_args (scm1 ());
+ return scm_apply_1 (scm1 (), arg1, scm_cdr (rest));
}
};