Hi Chapel Users and Developers —
Currently, Chapel's strings support a
.find() method that returns the position of a substring within a string, or
-1 if it is not found. In Add support for string.contains()? · Issue #19119 · chapel-lang/chapel · GitHub, I've proposed that we also support a
.contains() method that would simply return true or false if a string contained a given substring, to simplify cases where that's all that's needed, and to mirror
.contains() methods on other types (ranges, domains, collections, etc.).
If you have concerns about this proposal, please add them to the issue. If you support it, please give it a thumbs-up.
.contains(...) and array's
.contains(...) are both present in a language they are hard to distinguish for humans. this can cause the bugs often does not appear before runtime. That is a practical problem for people new to the language C#. Often I see people mix up String.Contains(String) and List.Contains(T). The code looks identical to the untrained eye.
I am all for the method
.contains(). it is comfortable and easy to understand.
I am concerned about compiler feed back and type safety. It looks almost the same as range.contains(ind: idxType ) and domain.contains(idx: _value.idxType ...rank ). You are proposing the same number of input and the same type of output as a the proc in range. that can be hard to detect.
@ahysing: Thanks for the feedback, though I'm not completely following. Can you clarify what the source of confusion would be—i.e., what might a user type and think they were doing that would only lead to confusion or a bug that only appears at runtime?
PS — Sorry for the slow response, I was out of the office last week.