19110, "bradcray", "Should the compiler warn when a pure routine's return value is not used?", "2022-01-26T00:43:37Z"
Summary of Problem
With the caveat that I'm not much of a string programmer, during Advent of Code, I found myself writing cases like:
s.strip();
rather than the required:
s = s.strip();
(which probably stems from my use of chomp() in Perl and request for chomp() in #18849). It took me an embarrassingly long time to realize why my code wasn't working.
This made me wonder whether the Chapel compiler could/should warn the user when a pure routine (one that has no side effects—or maybe we'd want the trigger to be something else) is called and the result is dropped on the floor, because such cases seem more likely to be due to a misunderstanding of the interface rather than intentional.
In module reviews, we've discussed other cases with the potential for confusion, like myArray.reshape(...) and potentially myString.replace(...) which could potentially be misinterpreted. Given the choice of clumsier names that make the lack of modification in-place more apparent or cleaner names and this warning, I'd take the latter.