SRL-PHP icon indicating copy to clipboard operation
SRL-PHP copied to clipboard

Syntax synomyms

Open francislavoie opened this issue 9 years ago • 23 comments

Already suggested from Reddit:

exactly as synonym to literally

either as synonym to either of

francislavoie avatar Aug 30 '16 00:08 francislavoie

Thank you.

Someone suggested any of instead of/as a synonym for either of. What do you think about that?

KarimGeiger avatar Aug 30 '16 03:08 KarimGeiger

I agree

francislavoie avatar Aug 30 '16 04:08 francislavoie

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.

zookatron avatar Aug 30 '16 05:08 zookatron

Wouldn't literal be better than exactly or literally? I find it easier to read as:

capture literal "@"

hoshsadiq avatar Aug 30 '16 06:08 hoshsadiq

literal would be way better, yes. In fact, exactly is already in use as a quantifier.

KarimGeiger avatar Aug 30 '16 08:08 KarimGeiger

"literal" could be a synonym to "exactly".

In fact, I prefer "exactly".

llagerlof avatar Aug 30 '16 14:08 llagerlof

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

KarimGeiger avatar Aug 30 '16 14:08 KarimGeiger

I said "exactly"? Sorry, I meant to say "literally".

llagerlof avatar Aug 30 '16 14:08 llagerlof

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.

francislavoie avatar Aug 30 '16 14:08 francislavoie

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.

KarimGeiger avatar Aug 30 '16 14:08 KarimGeiger

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 avatar Aug 30 '16 15:08 KarimGeiger

@KarimGeiger might be on to something! I think it's important for SRL to have an explicit word, but having it optional is great!

codyfletcher avatar Aug 30 '16 15:08 codyfletcher

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 avatar Aug 30 '16 16:08 thinkhuman

@thinkhuman Could usage of "match" be confusing as many languages use a match function to find capture groups? Just a thought!

SamTebbs33 avatar Aug 30 '16 16:08 SamTebbs33

What about non-character instead no character and non-whitespace instead of no whitespace?

ghost avatar Aug 30 '16 16:08 ghost

@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 avatar Aug 30 '16 16:08 thinkhuman

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

ghost avatar Aug 30 '16 16:08 ghost

By the way, why one of and any of are two different keywords? Why don't use them interchangeably?

Saluev avatar Sep 03 '16 13:09 Saluev

I think this would be confusing.

ghost avatar Sep 03 '16 13:09 ghost

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

llagerlof avatar Sep 03 '16 14:09 llagerlof

@nsgonultas But they are doing semantically the same thing.

Saluev avatar Sep 03 '16 16:09 Saluev

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.

ghost avatar Sep 03 '16 17:09 ghost

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?

hoshsadiq avatar Sep 06 '16 00:09 hoshsadiq