Page 1 of 1

SplitPath should probably be replaced with a path object

Posted: 13 Jul 2023, 16:17
by iseahound
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

Re: SplitPath should probably be replaced with a path object

Posted: 14 Jul 2023, 03:06
by just me
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

Re: SplitPath should probably be replaced with a path object

Posted: 14 Jul 2023, 10:22
by iseahound
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.