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

Fix the order of argument in (.) #1752

Merged
merged 4 commits into from
Jan 9, 2024
Merged

Fix the order of argument in (.) #1752

merged 4 commits into from
Jan 9, 2024

Conversation

yannham
Copy link
Member

@yannham yannham commented Jan 8, 2024

The curried dot operator (.) has been added to Nickel 1.3. However, due to an overlook of the order of arguments of the underlying primitive operator (DynAccess), the arguments of this operator have been flipped: in 1.3, (.) foo bar is bar."%{foo}" instead of foo.%{"bar"}.

While it's tempting to keep this way - in particular because it's very useful combined with the reverse application operator - this is both unintentional and inconsistent with every other curried operator. Although it's a breaking change, I believe it's the right price to pay to maintain consistency as much as possible and keep to the principle of least surprise for newcomers.

In addition to fixing the order of arguments for (.), a new function std.record.get has been added to the stdlib to make up for the previous usage of the flipped (.) in sequence of |> applications: any previous usage of (.) can safely be replaced with std.record.get.

@yannham yannham added this to the Next minor (1.4) milestone Jan 8, 2024
@github-actions github-actions bot temporarily deployed to pull request January 8, 2024 14:55 Inactive
RELEASES.md Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request January 9, 2024 09:25 Inactive
yannham and others added 4 commits January 9, 2024 10:57
Unfortunately, the output of the error message shows a closure address
(in practice, a memory address), which makes it non-determinstic and
thus unfit for a snpashot test.

Instead, it's been replaced with an integration test, which
Unfortunately won't allow to detect a deterioriation in error reporting,
but at least ensure that the contract of `std.record.get` works as
expected.
@yannham yannham enabled auto-merge January 9, 2024 09:58
@github-actions github-actions bot temporarily deployed to pull request January 9, 2024 10:02 Inactive
@yannham yannham added this pull request to the merge queue Jan 9, 2024
Merged via the queue into master with commit 6ffa6ac Jan 9, 2024
5 checks passed
@yannham yannham deleted the fix/curried-dot-op branch January 9, 2024 10:16
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.

2 participants