PenUltima Online

It is currently Sat Sep 06, 2008 8:25 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Setting to disable "unused variable" warnings in e
PostPosted: Thu Jul 06, 2006 2:14 am 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
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.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 06, 2006 1:50 pm 
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!!


Top
  
 
 Post subject:
PostPosted: Fri Jul 07, 2006 6:25 am 
Offline

Joined: Sun Mar 05, 2006 7:25 am
Posts: 118
Location: Italy
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 3:56 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
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.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 7:51 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
maybe just need to make ecompile ignore variables declared in the program params? This would solve everyone's problems wouldnt it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 9:43 pm 
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.


Top
  
 
 Post subject:
PostPosted: Mon Jul 10, 2006 10:06 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
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:
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.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 10:49 am 
Yukiko wrote:
Code:
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.


Top
  
 
 Post subject:
PostPosted: Tue Jul 11, 2006 2:43 pm 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
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.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 8:00 am 
Offline

Joined: Mon Jun 19, 2006 4:48 pm
Posts: 79
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 :P


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 28, 2006 9:37 am 
Offline

Joined: Sat Feb 04, 2006 5:49 pm
Posts: 748
Location: Chicago, IL USA
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...


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl