Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax synomyms #8

Open
francislavoie opened this issue Aug 30, 2016 · 23 comments
Open

Syntax synomyms #8

francislavoie opened this issue Aug 30, 2016 · 23 comments

Comments

@francislavoie
Copy link

Already suggested from Reddit:

exactly as synonym to literally

either as synonym to either of

@KarimGeiger
Copy link
Member

Thank you.

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

@francislavoie
Copy link
Author

I agree

@zookatron
Copy link

zookatron commented Aug 30, 2016

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.

@hoshsadiq
Copy link

hoshsadiq commented Aug 30, 2016

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

capture literal "@"

@KarimGeiger
Copy link
Member

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

@llagerlof
Copy link

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

In fact, I prefer "exactly".

@KarimGeiger
Copy link
Member

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

@llagerlof
Copy link

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

@francislavoie
Copy link
Author

francislavoie commented Aug 30, 2016

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.

@KarimGeiger
Copy link
Member

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
Copy link
Member

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

@codyfletcher
Copy link

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

@thinkhuman
Copy link

thinkhuman commented Aug 30, 2016

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 '@' ")

@SamTebbs33
Copy link

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

@ghost
Copy link

ghost commented Aug 30, 2016

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

@thinkhuman
Copy link

thinkhuman commented Aug 30, 2016

@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

@ghost
Copy link

ghost commented Aug 30, 2016

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

@Saluev
Copy link

Saluev commented Sep 3, 2016

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

@ghost
Copy link

ghost commented Sep 3, 2016

I think this would be confusing.

@llagerlof
Copy link

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

@Saluev
Copy link

Saluev commented Sep 3, 2016

@nsgonultas But they are doing semantically the same thing.

@ghost
Copy link

ghost commented Sep 3, 2016

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.

@hoshsadiq
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants