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

Add remove method for list #13148

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nobiit
Copy link

@nobiit nobiit commented Apr 25, 2024

sources = files('x.c y.c z.c'.split())
sources.remove(files('x.h z.c'.split()))

sources // y.c

@nobiit nobiit requested a review from jpakkane as a code owner April 25, 2024 22:20
@nobiit nobiit force-pushed the features/add_remove_for_list branch 2 times, most recently from 81ffddb to a23555b Compare April 25, 2024 22:32
@nobiit nobiit force-pushed the features/add_remove_for_list branch from a23555b to 6f1eaaa Compare April 25, 2024 22:32
@tristan957
Copy link
Contributor

Not sure whether I like it or not, but you have no tests, and no documentation

@dcbaker
Copy link
Member

dcbaker commented Apr 26, 2024

Meson objects are immutable once created, so any method like this would have to return a modified array without changing the original array. This is what += does, it’s a actually a short hand for x = x + y

@jpakkane jpakkane mentioned this pull request Apr 26, 2024
@jpakkane
Copy link
Member

As noted above, the method should be called something like .without() and it should return a new array. But even then this is problematic, because you can mix strings and file objects things get very complicated. If you build an array with a file foo.c in it in one directory and then remove foo.c in a different directory that also has a foo.c file, what should happen?

In order to add this it would require a fairly hefty real world use case. We never add functionality "just in case someone might need it later".

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.

None yet

4 participants