Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Generalize ellipsis as a ..rest argument (when rest-args enabled) #145

Merged
merged 5 commits into from
Jul 17, 2024

Conversation

dgkf
Copy link
Owner

@dgkf dgkf commented Jul 17, 2024

Closes #133; Inspired by the discussion in #133

vanilla

f <- fn(...) list(...)
f(1, 2, 3)
# list(1, 2, 3)

f <- fn(...) .
f(1, 2, 3)
# Error: object '.' not found

rest-args

f <- fn(...) list(...)
f(1, 2, 3)
# list(1, 2, 3)

f <- fn(...) .
f(1, 2, 3)
# list(1, 2, 3)
  • Treats ... as a "rest" argument, similar to any other "rest" argument using the "more" operator (..). When the rest-args experiment is enabled, ... gets parsed as a named ellipsis argument with the name ..

Other enhancements

  • Adds parse, and parse_and_eval as methods of CallStack to make it easier to write tests that make use of experiments
  • Cleans up some legacy uses of session.local.parse_input_with and replaces with parser_config.parse_input
  • Fixes feature disabled error message to display correct command to enabled features.
  • CallStack::default() now defaults to a global environment with pre-populated builtin functions instead of an empty environment.
  • Renamed parse_pairlist to parse_list_elements since we don't use a lisp-style "pairlist"

@dgkf dgkf merged commit a4ee2f1 into main Jul 17, 2024
12 checks passed
@dgkf dgkf deleted the 133-ellipsis-as-rest branch July 17, 2024 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ellipsis is exposed through evaluation environment of functions
1 participant