Opened 5 years ago

Closed 5 years ago

#1623 closed enhancement (fixed)

Avoid consing for optional procedure arguments

Reported by: sjamaan Owned by: sjamaan
Priority: minor Milestone: 5.2
Component: compiler Version: 5.0.0
Keywords: Cc:
Estimated difficulty: medium

Description

Currently, anything that accepts optional, rest or keyword arguments has to build a list and then pick that list apart. This is wasteful because it should not be necessary at all.

We could start with the low-hanging fruit like case-lambda and #!optional, where the binding of arguments and argument count checking is relatively simple. Handling #!key and #!rest or dotted tail rest argument notation is something that seems to me either too difficult and possibly not even worth it: you usually want to treat those as a list (but patterns like optional could still be handled specially, if nothing else refers to the identifier).

Attachments (2)

rest-args.patch (16.3 KB) - added by sjamaan 5 years ago.
Patch against e25965
0001-Replace-car-cdr-null-on-rest-args-with-direct-argvec.patch (21.3 KB) - added by sjamaan 5 years ago.
Final version including explanatory commit message sent to the mailing list

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by sjamaan

Summary: Implement faster vararg proceduresAvoid consing for optional procedure arguments

comment:2 Changed 5 years ago by evhan

Version: 5.0.0rc15.0.0

Moving to 5.0.0 just to keep the listings tidy.

comment:3 Changed 5 years ago by sjamaan

Milestone: someday5.2

comment:4 Changed 5 years ago by felix winkelmann

Milestone: 5.25.3

Changed 5 years ago by sjamaan

Attachment: rest-args.patch added

Patch against e25965

Changed 5 years ago by sjamaan

Final version including explanatory commit message sent to the mailing list

comment:5 Changed 5 years ago by felix winkelmann

Final version has been applied.

comment:6 Changed 5 years ago by sjamaan

Milestone: 5.35.2
Resolution: fixed
Status: newclosed

This has been implemented for #!optional, let-optionals* and also case-lamdba. There might be room for improvement (as always), but for now I feel we've done enough; the approach we use even makes manual accesses of rest arguments optimisable, depending on the exact pattern used, of course.

Note: See TracTickets for help on using tickets.