Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

20230720 call with rest #198

Merged
merged 28 commits into from
Aug 1, 2023

Conversation

prozacchiwawa
Copy link

Adds an &rest keyword to function argument lists. It specifies that the runtime value that follows will be used to provide
the rest of the argument list to this function as though each left subtree was specified as a separate argument and its tail
value would be captured by an improper tail argument in the same position.

&rest fills unspecified arguments with a runtime value:

in (defun F (A B . C) ...) called like (F &rest (list 101 103 105 109)), the body of F receives A = 101, B = 103, C = (105 109).

in (defun F (A B . C) ...) called like (F 13 &rest (list 101 103 105 109)), the body of F receives A = 13, B = 101, C = (103 105 109).

in (defun F (A B . C) ...) called like (F 13 15 19 &rest (list 101 103)), the body of F receives A = 13, B = 15, C = (19 101 103).

See https://github.com/Chia-Network/clvm_tools_rs/blob/20230720-call-with-rest/src/tests/compiler/restargs.rs for examples.

Will likely backport this and put a PR in at the base level as well.

@prozacchiwawa prozacchiwawa mentioned this pull request Aug 1, 2023
@prozacchiwawa prozacchiwawa merged commit fcd9e19 into 20230421-nightly-rebuild Aug 1, 2023
20 of 21 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant