Page 1 of 1
"Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 5:57 am
by Phantomas
Hello. I am surprised why it isn't exists yet!
Code: Select all
EnableExplicit
#constant = 0
Define int.i = 1
Define string.s = "hello"
Dim arr.s(4)
string = "hi"
Like that:
Warning: constant "#constant" is assigned but never used!
Warning: variable "int" (Integer) is assigned but never used!
Warning: variable "arr" (String, Array) is assigned but never used!
http://www.west-wind.com/Weblog/images/ ... a38576.png
http://d2o0t5hpnwv4c1.cloudfront.net/10 ... riable.png
Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 6:19 am
by leonhardt
like Delphi compiler

Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 12:18 pm
by Deluxe0321
Good idea for variables, but not for constans..
Think about the include files for libs etc. it would be annoying to see 2k 'Warning: constant "#constant" is assigned but never used!' messages.
Unsued constants could be execluded from the ASM output (if not done allready?) - to save memory

Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 12:27 pm
by Danilo
Constants are like macro replacements. This is the same:
Code: Select all
#CONSTANT = 12
Macro CONSTANT : 12 : EndMacro
Not used, nothing is included. Used, the value is inserted. (x = #CONSTANT and x = CONSTANT become both x = 12)
Other languages have const variables. Variables that are not write-able after assignment (you can read them and you can get a pointer to const variables).
This is not the same as PB constants.
Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 12:38 pm
by Deluxe0321
Thank you Danilo for making that clear.
Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 8:43 pm
by Joakim Christiansen
Would be nice, but may also come with an option to turn it off.
Re: "Variable/Constant/.etc never used" warning
Posted: Fri Mar 15, 2013 9:38 pm
by Josh
Yes, would be a nice feature. For me it would be enough, checked only when I start Compiler/SyntaxCheck