Am Do., 18. Juni 2020 um 11:55 Uhr schrieb Marc Nieper-Wißkirchen
<xxxxxx@nieper-wisskirchen.de>:
> >> I am not sure about the usefulness of the example, though. We have
> >> already case-lambda for an optimized version (given that the
> >> underlying Scheme has case-lambda as a core form):
> >>
> >> (define (complement fn)
> >> (case-lambda
> >> (() (not (fn)))
> >> ((x) (not (fn x)))
> >> ((x y) (not (fn x y)))
> >> (x* (not (apply fn x*)))))
> >
> >
> > Not all Schemes have case-lambda as a core form, and we should
> > not be in the business of discouraging axiomatic Scheme. In the
> > absense of special support for this, your definition is slower than
> > no optimization at all.
Addendum: In the case, FN is a variadic procedure like `+` and given a
decent case-lambda implementation, my definition is actually an
optimization while Shiro's original example code isn't.
The original example code also does not take into account that the
arity of FN can change (which it can if the arity is defined through
some dynamic property as SRFI 191 currently tries to do).