variadic arity
Alex Shinn
(17 Jun 2020 00:50 UTC)
|
Re: variadic arity
Alex Shinn
(17 Jun 2020 01:00 UTC)
|
Re: variadic arity
Alex Shinn
(17 Jun 2020 22:18 UTC)
|
Re: variadic arity
Arthur A. Gleckler
(17 Jun 2020 22:23 UTC)
|
Re: variadic arity Marc Nieper-Wißkirchen (18 Jun 2020 08:04 UTC)
|
Re: variadic arity
Alex Shinn
(18 Jun 2020 09:34 UTC)
|
Re: variadic arity
Marc Nieper-Wißkirchen
(18 Jun 2020 09:56 UTC)
|
Re: variadic arity
Marc Nieper-Wißkirchen
(18 Jun 2020 11:47 UTC)
|
Re: variadic arity
Alex Shinn
(18 Jun 2020 13:22 UTC)
|
Re: variadic arity
Marc Nieper-Wißkirchen
(18 Jun 2020 16:39 UTC)
|
On the old SRFI 102 list, Shiro Kawai gave an example of where it could be used ([1]). Let me quote: I rather think that the point of the arity query procedure is for some kind of crude optimization, rather than strict error checking, given the nature of the ambiguity Thomas mentioned. For example, higher order procedure can branch out the typical cases to avoid folding arguments (it can be abstracted to a macro). (define (complement fn) (case (arity fn) ;; some optimization ((0) (lambda () (not (fn)))) ((1) (lambda (x) (not (fn x)))) ((2) (lambda (x y) (not (fn x y)))) (else (lambda args (not (apply fn args)))))) (Note that this example has been written for the old API, but this is irrelevant.) 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*))))) Marc -- [1] https://srfi-email.schemers.org/srfi-102/msg/2772015/ Am Do., 18. Juni 2020 um 00:23 Uhr schrieb Arthur A. Gleckler <xxxxxx@speechcode.com>: > > On Wed, Jun 17, 2020 at 3:18 PM Alex Shinn <xxxxxx@gmail.com> wrote: > >> >> Note this wasn't rhetorical - I don't think a SRFI should be accepted without any examples. > > > That's a good point. I've put checking for examples in my finalization and new-draft checklists.