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

Discuss the future of the AutoHotkey language
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

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

15 Aug 2023, 05:48

image.png
image.png (170.74 KiB) Viewed 1780 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.
Descolada
Posts: 1141
Joined: 23 Dec 2021, 02:30

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

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
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

15 Aug 2023, 20:35

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.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

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

16 Aug 2023, 02:09

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.
Last edited by V2User on 16 Aug 2023, 06:30, edited 1 time in total.
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

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

16 Aug 2023, 03:21

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.
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

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

16 Aug 2023, 06:59

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.

Return to “AutoHotkey Development”

Who is online

Users browsing this forum: No registered users and 68 guests