Page 1 of 1
Setting to disable "unused variable" warnings in e
Posted: Thu Jul 06, 2006 2:14 am
by Yukiko
Yeah it's a small thing but I like to see clean compiles and many times those "unused" variables are used simply because they get assigned a value.
Anyway can you please give us a setting in eCompile.cfg for this.
Also, if you could address the case 'default' issue I posted about too.
Posted: Thu Jul 06, 2006 1:50 pm
by Marilla
Why do you need to create a variable only to assign a value to it, if you aren't going to use the value? And for that matter, doesn't assigning a value to a variable count as it being used? Isn't it only when you have a function parameter or a declared local var that you never use at all that this warning comes?
The biggest time this happens to me is with standard scripts for things like dot-commands or UseScripts, where the basic parameters are not used in the script; For instance, a dot-command that does not need to use the Char Ref or Text values; I prefer leaving the parameters defined just in case I might need them in the future (yes, I know it'd be easy as pie to add them back!), and I don't like doing the "who:=who;" trick)
Erm... with all that said; I have to agree that an ecompile.cfg option for this would be nice, to address the issue I note above. Of course, I'll live without it, but if it's an easy option to add, it'd be nice, indeed!!
Posted: Fri Jul 07, 2006 6:25 am
by Lagoon
I think there's a better solution to avoid the spam of unused variables in textcommands and similar scripts. Actually the "trick" is to do something like
unused_var :_= unused_var;
This avoids the warning, but adds unnecessary code. Imho it would be cool to add some instruction which is used to tell the compiler "I know I'm not using that variable, please don't print warning", something like
NOUSE unused_var;
or
nouse(unused_var);
which isn't really translated in istructions
Posted: Mon Jul 10, 2006 3:56 pm
by Yukiko
An eCompile option would be the most efficient alternative and it shouldn't be that hard to code into eCompile.
I see no reason why I, or anyone else for that matter, should have to create a special line of code in my scripts (or add one to other scripts (including the Distro code)) to stop the warnings.
I gather the warnings are there to promote optimized code but there are times when a variable is declared because it has to be but never gets "used" the way eCompile defines being used. See Marilla's post as an example.
Posted: Mon Jul 10, 2006 7:51 pm
by CWO
maybe just need to make ecompile ignore variables declared in the program params? This would solve everyone's problems wouldnt it?
Posted: Mon Jul 10, 2006 9:43 pm
by Marilla
No; I think it should be an option, if it's changed. I would still want to be aware of unused variables, including function/'program' parameters. Most of the time, they would be used for something, or could really be left out.
Posted: Mon Jul 10, 2006 10:06 pm
by Yukiko
Actually CWO the answer to your question is "No".
Note the following from POL 96/97 Distro spellStarter.src found in \Distro\pkg\skills\magery:
Code: Select all
program SpellStarter(params)
var mobile := params[1]; // Caster
var spell_id := params[2]; // Id # of the spell
var scroll := params[3]; // Scroll object being used
var targ := params[4]; // NPC target //This line generates an "unused" warning and targ is definitely used here.
...
The option cfg option is the best way to go.
Posted: Tue Jul 11, 2006 10:49 am
by Marilla
Yukiko wrote:
Code: Select all
program SpellStarter(params)
var mobile := params[1]; // Caster
var spell_id := params[2]; // Id # of the spell
var scroll := params[3]; // Scroll object being used
var targ := params[4]; // NPC target //This line generates an "unused" warning and targ is definitely used here.
...
Why would that line generate a warning, but the rest don't? If that's the case, sounds to me like there's just a bug in the reporting that needs to be fixed; a bug which adding this option (which I otherwise support) would just cover up.
Posted: Tue Jul 11, 2006 2:43 pm
by CWO
ya I wasnt saying ignore as in never being able to use them ever... I meant to not throw a warning when a program's params arent used.
Posted: Mon Aug 28, 2006 8:00 am
by DeiviD
i like the ideia really
oninserts and similar scripts have a load of (usually unused) params
plus sometimes you leave an unused var or two for future use or stuff like that
and who:=who sux, is useless and wastes cpu cicles

Posted: Mon Aug 28, 2006 9:37 am
by CWO
I was just looking over this topic yesterday too thinking maybe we got an answer and I just missed it.
Now rewriting my scriptbase I've severely slashed the number of instructions my shard's scripts do (and still going) and I instated a "No compile warnings" policy for the other shard devs but its hard to enforce that with these things and still say, dont do anything thats not truely needed... its either one or the other...