This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see BeyondCurryingHemann in WG2's repo for R7RS-large.

Beyond­Currying­Hemann

cowan
2017-07-02 06:42:35
3history
source

λ* : Beyond Currying

Notes:

The proposed name is lambda*, not λ*.

The proposal is Variant 5, which has no support for zero-argument or zero-or-more-arguments procedures, with the additional feature of Variant 8, supporting multi-expression bodies. Section 4 says "nullary λ∗ functions seem to be of little to no use", and I agree: they seem to be provided only so that lambda* can fully subsume lambda, which I think is a mistake (it makes detecting an error in the number of arguments at compile time impossible).

Here is the (not yet debugged) source code:

(import (scheme case-lambda)) (define-syntax lambda* (syntax-rules () ((_ a* e* ...) (lambda*-h a* (let () e* ...))))) (define-syntax lambda*-h (syntax-rules () ((_ (a a* ...) e) (posary-h (a a* ...) e)) ((_ (a a* ... . rest) e) (polyvariadic-h (a a* ... . rest) e)))) (define-syntax posary-h (syntax-rules () ((_ (a a* ...) e) (letrec ((rec (case-lambda (() rec) ((a a* ...) e) ((a a* ... . rest) (apply (rec a a* ...) rest)) (some ((lambda more (apply rec (append some more)))))))) rec)))) (define-syntax polyvariadic-h (syntax-rules () ((_ (a a* ... . rest) e) (letrec ((rec (case-lambda (() rec) ((a a* ... . rest) e) (some ((lambda more (apply rec (append some more)))))))) rec))))