Page 1 of 1

[Wish:] A dual syntax in V2 wished to eliminate

Posted: 15 Aug 2023, 05:48
by V2User
image.png
image.png (170.74 KiB) Viewed 2039 times
It seems that it makes no sense to provide three ways to achieve a same feature. If put aside the backward compatibility this time, making Match[N].Pos to be the only way might be better.

Re: [Wish:] A dual syntax in V2 wished to eliminate

Posted: 15 Aug 2023, 12:35
by Descolada
What are the three ways, and which one do you propose be removed?

Code: Select all

RegExMatch("V2User", "i)(?<first>v2)(?<second>user)", &m:="")
OutputDebug m["first"] ; User
OutputDebug m.second ; V2
OutputDebug m.1 ; V2
OutputDebug m.2 ; User
OutputDebug m.Pos["second"] ; 3
OutputDebug m.Pos("first") ; 1
OutputDebug m.Pos ; 1

Re: [Wish:] A dual syntax in V2 wished to eliminate  Topic is solved

Posted: 15 Aug 2023, 20:35
by lexikos
How would you like if I removed some syntax your scripts use in the next release, and told you to write it a different way?

Anyway, Match[N] is a string. Match[N].Pos cannot work.

Re: [Wish:] A dual syntax in V2 wished to eliminate

Posted: 16 Aug 2023, 02:09
by V2User
Descolada wrote:
15 Aug 2023, 12:35
What are the three ways, and which one do you propose be removed?

Code: Select all

RegExMatch("V2User", "i)(?<first>v2)(?<second>user)", &m:="")
OutputDebug m["first"] ; User
OutputDebug m.second ; V2
OutputDebug m.1 ; V2
OutputDebug m.2 ; User
OutputDebug m.Pos["second"] ; 3
OutputDebug m.Pos("first") ; 1
OutputDebug m.Pos ; 1
Yes, more than three.🤣 m.Pos(1), m.Pos("first"), m.1, m(1) wished to remove. m.Pos[1] and m[1] wished to be adopted.
But I give up now.

Re: [Wish:] A dual syntax in V2 wished to eliminate

Posted: 16 Aug 2023, 03:21
by lexikos
I think you fail to understand the concept of backward-compatibility. I told you before, you need to take it into account. If you do not, your suggestions may be rejected out of hand. Actually, I now notice you mentioned "put aside the backward compatibility". I do not understand how you can think that would even be an option.

Also, there are not more than three ways to get the same value. There are different properties for different values. This was already pointed out to you, but you seem to not understand.

The most common usage is to retrieve the value of the match or a captured subpattern, but you are saying that m.1 and m[1] should be removed and everyone should use m[1].String. I am not sure that any user other than you would want this, if the change was even permitted.

Instead of invoking Match.Pos, Match.Len and Match.Name on each iteration, you would be invoking Subpattern.Pos, Subpattern.Len and Subpattern.Name. Why do you think it would be faster? Your theory about performance also fails to take into consideration the overhead of creating an additional object for each subpattern.

There are just too many problems with your suggestion, as seems to be the case too often. Please put more thought into future suggestions before posting.

Re: [Wish:] A dual syntax in V2 wished to eliminate

Posted: 16 Aug 2023, 06:59
by V2User
lexikos wrote:
16 Aug 2023, 03:21
Instead of invoking Match.Pos, Match.Len and Match.Name on each iteration, you would be invoking Subpattern.Pos, Subpattern.Len and Subpattern.Name. Why do you think it would be faster? Your theory about performance also fails to take into consideration the overhead of creating an additional object for each subpattern.
There are just too many problems with your suggestion, as seems to be the case too often. Please put more thought into future suggestions before posting.
I am so sorry for disturbing. I have found a big mistake in my post replying to Descolada. 🤣 Therefore I deleted the sentence in 17:00, but I haven't caught up before you read it.
I have misunderstood the way the Match object to loop. Also, I am a new learner on regular expressions and I have misunderstood the subpattern which I treated as a item of all matched objects. I have mistaken the match object and "the overall match" in document as an array of all matched Strings. 🤣 I really shouldn't have reply it too hasty. Forgive me.