PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Setting to disable "unused variable" warnings in e

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
Yukiko



Joined: 02 Feb 2006
Posts: 1094
Location: Southern Central USA

PostPosted: Thu Jul 06, 2006 6:14 am    Post subject: Setting to disable "unused variable" warnings in e Reply with quote

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.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Thu Jul 06, 2006 5:50 pm    Post subject: Reply with quote

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!!

Author Message
Lagoon



Joined: 05 Mar 2006
Posts: 118
Location: Italy

PostPosted: Fri Jul 07, 2006 10:25 am    Post subject: Reply with quote

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

Author Message
Yukiko



Joined: 02 Feb 2006
Posts: 1094
Location: Southern Central USA

PostPosted: Mon Jul 10, 2006 7:56 pm    Post subject: Reply with quote

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.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 699
Location: Chicago, IL USA

PostPosted: Mon Jul 10, 2006 11:51 pm    Post subject: Reply with quote

maybe just need to make ecompile ignore variables declared in the program params? This would solve everyone's problems wouldnt it?

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jul 11, 2006 1:43 am    Post subject: Reply with quote

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.

Author Message
Yukiko



Joined: 02 Feb 2006
Posts: 1094
Location: Southern Central USA

PostPosted: Tue Jul 11, 2006 2:06 am    Post subject: Reply with quote

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.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Tue Jul 11, 2006 2:49 pm    Post subject: Reply with quote

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.

Author Message
CWO



Joined: 04 Feb 2006
Posts: 699
Location: Chicago, IL USA

PostPosted: Tue Jul 11, 2006 6:43 pm    Post subject: Reply with quote

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.

Author Message
DeiviD



Joined: 19 Jun 2006
Posts: 79

PostPosted: Mon Aug 28, 2006 12:00 pm    Post subject: Reply with quote

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 Razz

Author Message
CWO



Joined: 04 Feb 2006
Posts: 699
Location: Chicago, IL USA

PostPosted: Mon Aug 28, 2006 1:37 pm    Post subject: Reply with quote

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...

Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty