Declaration of Variable Option
Declaration of Variable Option
Option to require variables to be declared in the script or by compiler option. Something like @OPTIONS {DeclareVariable = True} or compiler opt -DeclareVariable.
- airsoftsoftwair
- Posts: 5830
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Declaration of Variable Option
Actually, I've thought about something like this several times but then decided against it because this has the potential to cause lots of trouble, e.g. 3rd party includes containing some library code etc. could stop working if they aren't designed to be compatible with a mode that requires declaration of variables and there are several other tricky issues to consider here so this is unlikely to come.
Re: Declaration of Variable Option
How about using preprocessor directive? Like @IFUNDECLARED ERROR or @IFUNDECLARED WARNING directive. This would limit the scope of the check to just code inside @IFUNDECLARED.
example:
@IFUNDECLARED ERROR
code.....
@ENDIF
example:
@IFUNDECLARED ERROR
code.....
@ENDIF
- airsoftsoftwair
- Posts: 5830
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: Declaration of Variable Option
Yeah, but I think there are lots of other potential issues when making variable declaration a must. I've definitely been experimenting with this already in the past but then encountered some issues that made me drop the idea again, even though I don't remember exactly what it was. All I know is that the idea to add a variable declaration option has been around for some 15+ years or so.