? Duplicate variables in function arguments do not cause an error (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Duplicate variables in function arguments do not cause an error

  • #1 ✎ 1619 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself These programs should all throw duplicate variable errors, but they do not: This one isn't so bad, but the second input value cannot be accessed: DEF FUNCTION X,X PRINT X 'this accesses the first input value END The rest will usually cause an "Uninitialized value" error, because the output variables are inaccessible and can't be set. DEF FUNCTION OUT X,X X=1 'this only modifies the first X ENDDEF FUNCTION OUT X VAR X X=1 'this modifies the variable created by VAR, not the OUT variable. ENDDEF FUNCTION X OUT X X=4 'this modifies the input X, not the output X END This bug causes a lot of confusion because people will try to write functions like DEF MOVE X,Y OUT X,Y, which will not work as intended, as well as trying to use VAR to declare OUT variables. (It might be better if DEF FUNCTION X OUT X was treated as DEF FUNCTION X_IN OUT X : X=X_IN, because this will act the way people expect) Posted Edited by 12Me21