bugMIT/GNU Scheme - Bugs: bug #63454, let-values expansion is suboptimal

 
 

bug #63454: let-values expansion is suboptimal

Submitter:  Taylor R. Campbell <riastradh>
Submitted:  Thu 01 Dec 2022 01:11:54 PM UTC
   
 
Category:  runtime Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Suboptimal behavior
Status:  Fixed Privacy:  Public
Assigned to:  cph Originator Name: 
Open/Closed:  Closed
Keywords: 
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 01 Dec 2022 01:11:54 PM UTC, original submission:  

(pp (syntax '(let-values (((x) 5) ((y) 3))
               (list x y))
            (nearest-repl/environment)))
(let ((temp-0 (lambda () 5)) (temp-1 (lambda () 3)))
  (call-with-values
   temp-0
   (lambda (x)
     (call-with-values temp-1 (lambda (y) (list x y))))))

This has a high cost at runtime because the compiler knows nothing about multiple-value returns, so it makes let-values unfit for use in general-purpose macro expansion like foof-loop without a substantial performance penalty.

Expected result:

(pp (syntax '(let-values (((x) 5) ((y) 3))
               (list x y))
            (nearest-repl/environment)))
(let ((y 3) (x 5))
  (list x y))

I wrote a let-values in syntax-rules years ago that generates call-with-values only when necessary, attached.  (However, it doesn't work in MIT Scheme right now because of bug #63438.)

Taylor R. Campbell <riastradh>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #54045:  let-values.scm added by riastradh (5KiB - text/x-scheme)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cph (Updated the item)
  • -email is unavailable- added by riastradh (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-06 cph StatusNone Fixed
        Assigned toNone cph
        Open/ClosedOpen Closed
    2022-12-01 riastradh Attached File- Added let-values.scm, #54045

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code