Closed rasteiner closed 2 years ago
Also... Array
on Array
search. Should it return true
when all elements are found (like now) or if "some" of the elements are found? Or maybe return the "number of found elements"?
What about to introduce a custom expression language?
For example:haystay OR needle
or haystay NE needle
.
eq
= ===
ne
= !==
or
= ||
lt
= >
lte
= >=
That is probaly (better) understandable for users without devlopment background. You could use even full words like equal
.
The currently supported comparison and equality operators are: =
, !=
, <
, <=
, >
, >=
and =~
(the search operator, the one this issue is about).
I don't really have many doubts about these other ones, technically they're much easier to parse than "keywords" and they eliminate the chance of ambiguity between identifiers and keywords (like if someone calls their textfield "equal"). There are ways to solve this, like doing stuff like :equal:
or :lte:
, but I don't feel like they would be easier to understand for the majority of people editing yml files.
This issue is only about the =~
operator, for which there isn't really an established language I know to copy from.
The problem it solves is that the expression language here doesn't allow function calls, therefore without this special operator it's not possible to do something like textfield.includes('foo')
to check if "textfield" contains "foo".
But maybe I actually could do keywords for different search operations. Like textfield :include: "foo"
, so that I could cover different search methods, like for example textfield :start: "foo"
, array :all: [1,2,3]
, array :some: [1,2,3]
, etc...
The problem it solves is that the expression language here doesn't allow function calls
Another option would be to just allow function calls, maybe restricted to an "allow list"
I'm not sure on the ordering of the operands... Should it be:
haystack =~ needle
orneedle =~ haystack
? Orneedle =~ haystack
andhaystack ~= needle
? Or is that too confusing?Really open for suggestions and discussion