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

[FAQ] Is It Possible to Unify KCL and Python Regex Interfaces? #1689

Open
andrzejgorski opened this issue Oct 14, 2024 · 1 comment
Open

Comments

@andrzejgorski
Copy link

Is It Possible to Unify KCL and Python Regex Interfaces?

Is your feature request related to a problem? Please describe:
When working with regular expressions (regex), I've encountered a significant inconsistency between KCL and Python that has led to confusion and wasted time. This discrepancy exists in the way each language handles the regex.match function.

In KCL regex match has interface:

regex.match(key, pattern)

while in python

regex.match(pattern, key)

Sources:
https://www.kcl-lang.io/docs/reference/model/regex#match
https://docs.python.org/3/library/re.html#re.match

Describe the feature you'd like:
Change an order of parameters of regex.match function in KCL

@Peefy
Copy link
Contributor

Peefy commented Oct 15, 2024

Yes, the issue you mentioned does exist. It was a consideration when designing the parameter order in the KCL regex package. Initially, we thought about keeping it consistent with Python, but in order to simplify the functionality, the function and parameter names in the entire regex package were not consistent with Python. KCL hopes to make a simpler Python like language instead of being compatible with it. In addition, not all languages have parameter order of (pattern, input), such as C# is also (input, pattern). Although adjusting the parameter order can be considered, it will break the existing module ecosystem and KCL code. 😢

@Peefy Peefy changed the title Is It Possible to Unify KCL and Python Regex Interfaces? [FAQ] Is It Possible to Unify KCL and Python Regex Interfaces? Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants