SplitPath should probably be replaced with a path object

Discuss the future of the AutoHotkey language
iseahound
Posts: 1456
Joined: 13 Aug 2016, 21:04
Contact:

SplitPath should probably be replaced with a path object

Post by iseahound » 13 Jul 2023, 16:17

I think in answer to the long standing question of what to do with SplitPath, it might be best to replace it with a simple path object.

For example,

Code: Select all

drive := Path("C:/Windows").drive
SplitPath should coexist with Path.

jeeswg's approach https://github.com/AutoHotkey/AutoHotkey/pull/296

just me
Posts: 9530
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SplitPath should probably be replaced with a path object

Post by just me » 14 Jul 2023, 03:06

As jeeswg's pull request shows, we don't need an additional function. SplitPath(Path) could return a path object, if all output parameters are omitted:

Code: Select all

drive := SplitPath("C:/Windows").drive

iseahound
Posts: 1456
Joined: 13 Aug 2016, 21:04
Contact:

Re: SplitPath should probably be replaced with a path object

Post by iseahound » 14 Jul 2023, 10:22

No, I am suggesting an additional class while leaving SplitPath as-is. There are more properties that could be added such as .parent, the short 8.3 filename, and more. In addition, if operator overloading is added, the division operator / could be used for paths like in other languages.

Post Reply

Return to “AutoHotkey Development”