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

Remove usages of Call::positional_nth #12871

Merged
merged 2 commits into from
May 15, 2024

Conversation

IanManske
Copy link
Member

Description

Following from #12867, this PR replaces usages of Call::positional_nth with existing spans. This removes several expects from the code.

pub fn positional_nth(&self, i: usize) -> Option<&Expression> {
self.positional_iter().nth(i)
}

// TODO this method is never used. Delete?
pub fn positional_nth_mut(&mut self, i: usize) -> Option<&mut Expression> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should remove it. It seems like a useful method and can be used inside plugin.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disagree, we should have a minimal stable interface for the plugins now, and can add things back if there is a proven need.

I think the semantic meaning of mutating Expressions of a Call is weird (bar mem::take but only if proven useful). As a plugin you should only concern yourself with the resulting Values and associated Span.

Copy link
Member Author

@IanManske IanManske May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe Call is exposed to plugins. Rather, plugins use the EvaluatedCall type.

Although, it looks like Call does appear in the signature of EvaluatedCall::try_from_call.

@sholderbach sholderbach added the pr:api-change This PR should be mentioned in #api-updates channel on Discord label May 15, 2024
@sholderbach sholderbach merged commit 06fe7d1 into nushell:main May 15, 2024
15 checks passed
@hustcer hustcer added this to the v0.94.0 milestone May 16, 2024
FilipAndersson245 pushed a commit to FilipAndersson245/nushell that referenced this pull request May 18, 2024
# Description
Following from nushell#12867, this PR replaces usages of `Call::positional_nth`
with existing spans. This removes several `expect`s from the code.

Also remove unused `positional_nth_mut` and `positional_iter_mut`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:api-change This PR should be mentioned in #api-updates channel on Discord refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants