mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.3k stars 1.52k forks source link

Add remove method for list #13148

Open nobiit opened 3 weeks ago

nobiit commented 3 weeks ago
sources = files('x.c y.c z.c'.split())
sources.remove(files('x.h z.c'.split()))

sources // y.c
tristan957 commented 3 weeks ago

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

dcbaker commented 3 weeks ago

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 commented 3 weeks ago

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".