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
[eCompile] Unused include file
Goto page 1, 2, 3  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
Developer Silver



Joined: 05 Feb 2006
Posts: 58
Location: Italy

PostPosted: Thu Nov 30, 2006 5:29 pm    Post subject: [eCompile] Unused include file Reply with quote

A suggestion based upon ecompile's feature to automatically exclude unused functions from generated .ecl: should be possibile to have a warning like "Unused include file: xxx.inc" if neither functions nor variables/constants are used from a declared include file?

Alternative: the .dep files could have written the number of "hit" of each .inc? This way files with 0 hit could be removed from includes... Wink

This could save so much time compiling scripts! Very Happy

Author Message
qrak



Joined: 05 Feb 2006
Posts: 160
Location: Poland

PostPosted: Fri Dec 01, 2006 7:52 am    Post subject: Reply with quote

Good feature suggestion. Excluding unused functions would be good to minimize .ecl size

Author Message
Austin
POL Developer


Joined: 30 Jan 2006
Posts: 354
Location: San Diego, California

PostPosted: Fri Dec 01, 2006 8:49 am    Post subject: Reply with quote

It already does this.
Make an include with a function that has errors in it, include it in a script but dont call the function, itll still compile because it never uses the function's code.

Author Message
Developer Silver



Joined: 05 Feb 2006
Posts: 58
Location: Italy

PostPosted: Fri Dec 01, 2006 1:33 pm    Post subject: Reply with quote

Austin wrote:
It already does this.
Make an include with a function that has errors in it, include it in a script but dont call the function, itll still compile because it never uses the function's code.


I don't understand if you replied to qrak or to me Razz
In second case: I know this, in fact I didn't suggest that to reduce .ecl size, but compiling time. Wink

We have about 1300 .src and 200 .inc, and during last months I've heavly modified .inc functions distribution, so now we need a way to delete unused includes to avoid useless script recompiling (even if they're not used, ecompile detects updated .inc and recompiles scripts).

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Fri Dec 01, 2006 8:24 pm    Post subject: Reply with quote

You oughtta try to be more careful about how many include... statements you toss in places. I'm not really sure how practical it is to try to have the compiler going through and NEGATIVELY checking for functions/identifiers used from include files; seems like it would make the compile process take longer, every single time, because it would always have to be digging around looking for functions that you -don't- use, which seems a big waste of effort.

Basically, since you can't keep from adding extraneous 'include' statements, you would be making MY compile times take longer by having ecompile looking for things that I don't think it should bother taking the time to look for.

If you really have a problem with this, I think you may want to consider a serious re-organization of your include files. Under most circumstances, it should be fairly intuitive when you need an include or not - because your includes should contain logical groups of functions and identifiers that you obviously either need, or don't need.


I've seen people posting that basically make it sound like their 'debugging' of scripts amounted to commenting in and out include files until stuff compiles. That just suggests such a mess that I wonder how people can expect to make sense out of anything at all.

Author Message
MuadDib
POL Developer


Joined: 13 Feb 2006
Posts: 830
Location: Indiana, USA

PostPosted: Fri Dec 01, 2006 10:29 pm    Post subject: Reply with quote

If calls are recorded in the files......... someone could just as easily make a script to clean based on those Very Happy

Author Message
Developer Silver



Joined: 05 Feb 2006
Posts: 58
Location: Italy

PostPosted: Mon Dec 04, 2006 6:23 am    Post subject: Reply with quote

Marilla wrote:
I'm not really sure how practical it is to try to have the compiler going through and NEGATIVELY checking for functions/identifiers used from include files; seems like it would make the compile process take longer, every single time, because it would always have to be digging around looking for functions that you -don't- use, which seems a big waste of effort.

While ecompile parses .src file, it already scans included files in order to find used functions... so it should be easy to track how many calls are made at every .inc (this could also be a boolean, it's not interesting exactly how many calls, it's important only 0 or >0)... this way your compile process shouldn't be slower, but you can see which includes have 0 calls and are not necessary. Smile

MuadDib wrote:
If calls are recorded in the files......... someone could just as easily make a script to clean based on those

Oh yes, you can also use UltraEdit's search function to find unused includes Wink

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Mon Dec 04, 2006 6:45 am    Post subject: Reply with quote

Developer Silver wrote:
...you can see which includes have 0 calls and are not necessary. Smile


Perhaps, but I can also see this causing trouble when people don't realize that just because they aren't using a function/identifier in an include, does not mean the include is not needed, as I suspect you might not realize Razz

For instance, perhaps an include exists to aggregate other includes which are frequently - but not always - needed together, to avoid the need for excessive include statements in the source. Or perhaps such an include really does have functions in it, but it just so happens none of them are used. Remove that include based on the fact that none of it's functions/identifiers are used, and you may end up having trouble with includes that file itself defined.

While it could be argued that it would be better to simply include all of your individual files themselves (and I would argue that), I've seen all sorts of twisted and confusing stuff with includes, and it would surprise me NOT to see something like the above. The problem? Without needlessly complex issues like that, and with a generally good structure for how includes are used, such a feature really isn't all that important.


So, it's sort of like... the problem for which you think you want the feature may actually make it difficult to even use the feature in the first place.

Author Message
SMJ



Joined: 10 May 2006
Posts: 113

PostPosted: Mon Dec 04, 2006 9:16 am    Post subject: Reply with quote

I can understand where you're coming from with the suggestion; saving discspace and whatnot. However, I really don't see how something like this would be especially helpful. If I get the feeling that an include file or a particular function is un-needed, I just stuck "--" or "__" before the file or function name, respectively, then recompile the entire scriptbase and wait for error messages.

Author Message
Developer Silver



Joined: 05 Feb 2006
Posts: 58
Location: Italy

PostPosted: Mon Dec 04, 2006 10:52 am    Post subject: Reply with quote

@Marilla: using this feature in ecompile makes impossible to generate false positive, I think... calling a function in a file included in another include, should make both used in ecompile listing... see example below.

@SMJ: disk space is not our problem, the main goal is reducing compile time deleting unused includes Wink
Your suggestion is what we're doing now, but testing every include in every script everytime we update something, is impossible Wink



Maybe I've not been clear... I'll do an example...

test.src
Code:
include "inc1";
include "inc2";

program test()
   CallInc1b();
endprogram


inc1.inc
Code:
include "inc1b";

function CallInc1()
   Print("Calling CallInc1 from inc1.inc");
endfunction


inc1b.inc
Code:
function CallInc1b()
   Print("Calling CallInc1b from inc1b.inc");
endfunction


inc2.inc
Code:
include "inc2b";

function CallInc2()
   Print("Calling CallInc2 from inc2.inc");
endfunction


inc2b.inc
Code:
function CallInc2b()
   Print("Calling CallInc2b from inc2b.inc");
endfunction


At compiling time ecompile could prints out "Unused inc2.inc in test.src"... or in .dep file:

test.dep
Code:
C:\pol\scripts\test.src
C:\pol\scripts\inc1.inc 1
C:\pol\scripts\inc1b.inc 1
C:\pol\scripts\inc2.inc 0
C:\pol\scripts\inc2b.inc 0


The 0s mean that inc2.inc can be safely removed from test.src

Anyway, this is not so vital... it was only (for us) a usefull feature Smile

Author Message
Tritan



Joined: 04 Feb 2006
Posts: 136
Location: Illinois, USA

PostPosted: Mon Dec 04, 2006 3:00 pm    Post subject: Reply with quote

I do this just like SMJ does. When I working on a script I start removing the includes to see is really needed. I know what most my includes hold since they are broken up fairly well in the packages.

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Mon Dec 04, 2006 6:02 pm    Post subject: Reply with quote

Developer Silver wrote:
@Marilla: using this feature in ecompile makes impossible to generate false positive, I think...


This is what I was talking about:

Code:

include "inc1";

program DoIt(who)
   CallInc2Function();
endprogram


inc1:

Code:

include "inc2";
....other stuff not used in the .src...


inc2:

Code:

function CallInc2Function()
   ...
endfunction



In your example, ecompile would report - correctly - that no functions are used from inc1. However, if you remove inc1 from the .src, you will break it. Obviously, no one would ever do what I've done in the above simple example. But also just as obviously, if you look through the actual includes I've often seen, the above effectively happens a whole lot.


========================


I think that a combination of what Tritan and SMJ have mentioned, coupled with re-organizing your include files, will solve the problem much better. I think people create includes very improperly, a lot of the time. For instance, with apologies to any former distro devs (and I don't know - maybe these includes are no longer in the distro?), I think that includes like 'myutil' and 'std' are just completely horrid. Well, beyond the fact that the large majority of functions in them can probably be killed completely due to features the core now has (especially the std.inc I used to have way back from 092! hehe), I also think that 'catch-all' includes like that make for very messy code.

Now, there may be times when you will have some 'master functions' that you just use ALL the time. But includes like myutil and std don't have functions like that in them, to be honest. They have a bunch of often completely unrelated functions that (if core support had not been added) can be useful from time to time in this or that thing.


The problem with includes like this is simple: Changing one function in them for some purpose will end up with you having lots of .src files recompiled needlessly (which is what I know your issue is here - and I agree that it's a good goal, to eliminate needless recompiles due to includes. I just think you are barking up the wrong tree to accomplish it)


So, maybe myutil has a function in it to, say, open the player's web browser. Fine. (though again, it's now a core function, but stay with me here). Then maybe it also has a function to... I dunno... do anything else at all. Think about this a second:

In what logical way is the "DoAnythingElseAtAll()" function related to the "OpenWebBrowser()" function? The answer is 'in no way'. The logical conclusion should then be, "These two functions do not belong, therefore, in the same include".

My solution was very, very simple: I created an include for the web browser function and it's helper functions alone. There were no other functions at all that were 'related' to them, so I put no other functions in that include.


So, if I ever change the web browser include file, I can rest assured that only .src files that actually use the web browser function will be recompiled.



I do this same thing for all includes: I only put functions/identifiers together in an include when those functions/identifiers are logically connected to each other. This means I end up 'splitting up' includes a lot - I have a lot of includes with only a couple functions, and those includes are named such that when I look at the include area of a .src file, it's obvious what includes are there, and why. I never need to ask myself, "does this .src use that include?"


And then something that has been mentioned related to includes elsewhere; includes including other includes; Some people think that's just plain bad, right from the start. I think it *can* be bad, and confusing, but I also think it's absolutely necessary to accomplish the type of organization I do.

For example, take my WebBrowser include. As you may know, that include needed some functions to convert characters into hex and such, to build the packet to send. But what if I also needed those functions elsewhere?

I would put those functions themselves in another include - again, only with related functions. Then, I would include that include from within the web browser include, and whatever other scripts/includes needed those functions would also include it.

What I would NEVER do: Create duplicate copies of those functions and put them in multiple source files. (That's when you start getting the lovely "Expected identifier, got user function instead" error).

Author Message
Developer Silver



Joined: 05 Feb 2006
Posts: 58
Location: Italy

PostPosted: Mon Dec 04, 2006 6:45 pm    Post subject: Reply with quote

In my suggestion, your example works anyway: DoIt calls CallInc2Function, which is in inc2.inc... but to reach inc2.inc, ecompile must pass through inc1.inc, and so it marks both includes file Wink

About includes organization, I know what you mean, but I was thinking that if this feature is not so difficult to implement (the .dep alternative, at least), it could be an aid for everyone organization... Smile

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Mon Dec 04, 2006 7:29 pm    Post subject: Reply with quote

Developer Silver wrote:
About includes organization, I know what you mean, but I was thinking that if this feature is not so difficult to implement (the .dep alternative, at least), it could be an aid for everyone organization... Smile


Perhaps insofar as it tells you what you already should know: Your includes are screwed up Razz I'd rather my eCompile did not take the extra time, personally.

Author Message
Yukiko



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

PostPosted: Tue Dec 05, 2006 1:25 am    Post subject: Reply with quote

I have no comment about this really other than if it is implemented please make it a switchable option in ecompile.cfg. I can see the listings getting messier with

"Warning - include file stuff.inc referenced but no calls made to it in line 4.
Warning - variable junk not used in line 24"

etc.

Post new topic   This topic is locked: you cannot edit posts or make replies.    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 




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