Alex Rivera | Logout

Delphi: Which are the downsides of having unused units listed in the uses clause?

Asked 2010-12-23T14:42:25.397
10

I use cnPack Uses cleaner, but in general which are the downsides of having useless units?

I know some of them:

1) of course if the unit is never used across the full project there will be useless resource consuption

2) the code insight will give useless results

3) the code insight will be slower

But imagine a simple case:

  • I have a project with 2 forms, I use StrUtils in one of them but I declared StrUtils in both of them... Is there any downside in temrs of memory consumption in this case or not?
Edit
Report

1 Answer

6

The biggest problem, to my mind, is that you can sometimes get caught out by Delphi scoping rules. If you have two identifiers with the same name in different units, then using this name refers to the one declared in the unit declared latest in the uses clause.

If you suffer from a problem due to this you can always fully specify the identifier. What I would really love to see would be compiler warnings to tell you if you are naming an identifier that whose identity is only determined by this latest declaration in uses clause scoping rule.

answered 2010-12-23T16:45:48.267

Your Answer