=> throw(Error())

Propose new features and changes
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

=> throw(Error())

17 Jan 2024, 22:26

It seems as if throw is not allowed after the fat arrow character =>. It generates the following load error:
The following reserved word must not be used as a variable name:
"throw"
Assuming there are no breaking changes, it would be convenient if it was. Below is a simple use case for it:

Code: Select all

class foo {
   __New() => throw(Error('This class should not be instantiated.'))
}
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
User avatar
V2User
Posts: 195
Joined: 30 Apr 2021, 04:04

Re: => throw(Error())

18 Jan 2024, 00:16

This has been supported in AHK V2.1 alptha version.
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: => throw(Error())

18 Jan 2024, 02:36

Thank you. I wasn't aware of that. Much appreciated.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: => throw(Error())

19 Jan 2024, 01:53

=> takes an expression. Expressions cannot contain control flow statements, just like you can't use return throw(...) in v2.0. Throw is a function in v2.1-alpha.3+.
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: => throw(Error())

19 Jan 2024, 03:22

Thank you. Since throw was listed in the Alphabetical Function Index, I thought it was a function in v2.0 as well.
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)
lexikos
Posts: 9592
Joined: 30 Sep 2013, 04:07
Contact:

Re: => throw(Error())

19 Jan 2024, 05:08

The very first entry of the Alphabetical Function Index is "{ ... } (Block)", which clearly isn't a function... or even alphabetical. ;)

All of the other control flow statements should be there, too.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 60 guests