SRL-PHP
SRL-PHP copied to clipboard
Syntax synomyms
Already suggested from Reddit:
exactly as synonym to literally
either as synonym to either of
Thank you.
Someone suggested any of instead of/as a synonym for either of. What do you think about that?
I agree
I think it's actually really important to support any of as an alternative to either of. The more I use it the more confusing and flow-breaking it is to use either of. The phrase any of is much easier to understand and slightly easier to write.
Wouldn't literal be better than exactly or literally? I find it easier to read as:
capture literal "@"
literal would be way better, yes. In fact, exactly is already in use as a quantifier.
"literal" could be a synonym to "exactly".
In fact, I prefer "exactly".
@llagerlof but what about the quantifier? What if you want to match something exactly 3 times? I think using exactly for both characters and quantifiers would be insane...
I said "exactly"? Sorry, I meant to say "literally".
How do you feel about breaking language changes? Like replacing either of entirely with any of? Just wondering how much backwards compatibility matters at this stage.
I'll try to avoid it as much as possible. If there will be any breaking changes, I'm going to deprecate the old syntax first, before removing it completely in a later release.
Just a quick thought.. maybe it even makes sense to remove the literally keyword completely and just assume you're expecting the literal text if there's a "lost" string in quotes. I don't know if this would break something, though:
literally "foo" once or more
would become
"foo" once or more
@KarimGeiger might be on to something! I think it's important for SRL to have an explicit word, but having it optional is great!
In my eagerness I entered a similar issue. Strong +1 to changing "either" to "any", but I propose changing "literally" to "match" ("Match '@' ", not "Literally '@' ")
@thinkhuman Could usage of "match" be confusing as many languages use a match function to find capture groups? Just a thought!
What about non-character instead no character and non-whitespace instead of no whitespace?
@SamTebbs33 fair point, though finding language-agnostic words might prove difficult.
Maybe "Matching"? As in
begin with any of (number, letter, one of "._%+-") once or more,
matching "@",
letter at least 2 times,
must end, case insensitive
@thinkhuman I don't think that's a good idea. It can really be confusing.
for example => matching ".{2}"
ab matching with .{2} but there is no doubt about what literally ".{2}" means.
By the way, why one of and any of are two different keywords? Why don't use them interchangeably?
I think this would be confusing.
I think we are leaving the purpose of this tool. "literally" is, literally, the best english word to write when you meant to write literally "something".
@nsgonultas But they are doing semantically the same thing.
Yes, they are semantically similar, but:
regex equivalent of one of(i.e. [...]) only accepts characters and character classes,
regex equivalent of any of(i.e. (?:...|...|...) can accept more complicated things.
In my opinion, using them interchangeably will confuse beginners.
There's too much being discussed here, it's hard to keep track of what's going on. Does it make sense to separate these out? And potentially moving this to the simpleregex/language repo?