kcl icon indicating copy to clipboard operation
kcl copied to clipboard

Is It Possible to Unify KCL and Python Regex Interfaces?

Open andrzejgorski opened this issue 1 year ago • 1 comments

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

andrzejgorski avatar Oct 14 '24 00:10 andrzejgorski

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 avatar Oct 15 '24 02:10 Peefy