-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate 'function' keyword #2463
Comments
I guess I'll go check the manual for old examples with function. EDIT: There are are 147 references, of which most are event handlers. |
About ags3 , check #1331 (comment) I think void in ags3 is actually int for compatibility because some old games returned something in a |
Yes, I thought so. That's part of why I think AGS 4.0 is a good opportunity to fix it. |
To clarify, today |
The old compiler returns The new compiler does not do this: When a function is The new compiler already balks when it encounters |
The header file for AGS code has
|
I think there are two reasonable paths: If we want to keep "function" as a valid keyword, then it must be implemented in compiler as a keyword, with the rule to be only used in function declaration/definition. If we want to stop using "function", then:
|
When I see a For 4. and the current manual, I could replace |
As mentioned in the original issue, it would be possible to start by doing steps 2-4, so that |
Describe the problem
The
function
keyword is a legacy of ancient AGS scripting. Many of the default functions that are called by the engine use it as their return type. Because it is implemented as an alias ofint
but is used even if the function doesn't actually return anything, it means that AGS script cannot properly distinguishint
andvoid
return types.It also creates inconsistency, with two/three different ways to write the same function. This arguably creates confusion and makes the AGS scripting language harder to learn.
Suggested change
Remove
function
as a keyword. Change all function definitions to useint
orvoid
as appropriate, and make sure the editor uses these when creating event handlers. This also requires an update to the manual and to the templates.Optionally, update the compiler to require a correct return type (do not allow a bare
return;
if the return type is declared asint
, or areturn 1;
if the return type is declared asvoid
).Optionally, add a backwards script compatibility option to retain
function
as a keyword (still as an alias forint
). (Note that if the other optional part is implemented, this would still require users to change all functions that need to havevoid
as their return type, unless that is also disabled if the script compatibility option is set.)Alternative suggestion
Alternatively, don't remove
function
as a keyword, but change all the built-in functions to eitherint
orvoid
as appropriate (including in the manual and templates), so thatfunction
never appears unless you specifically add it.The text was updated successfully, but these errors were encountered: