1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-19 02:00:26 +02:00

Simplify let-values to let if consumer binds only one variable

* module/language/tree-il/peval.scm (peval): let-values with a consumer
  that has only one argument is the same as let.

* test-suite/tests/peval.test ("partial evaluation"): Add test.
This commit is contained in:
Andy Wingo 2013-05-28 11:20:29 -04:00
parent 4828538940
commit 64fc50c294
2 changed files with 10 additions and 1 deletions

View file

@ -979,6 +979,10 @@ top-level bindings from ENV and return the resulting expression."
;; reconstruct the let-values, pevaling the consumer.
(let ((producer (for-values producer)))
(or (match consumer
(($ <lambda-case> src (req-name) #f #f #f () (req-sym) body #f)
(for-tail
(make-let src (list req-name) (list req-sym) (list producer)
body)))
(($ <lambda-case> src req opt rest #f inits gensyms body #f)
(let* ((nmin (length req))
(nmax (and (not rest) (+ nmin (if opt (length opt) 0)))))