[Lazarus] When adding a packages it adds to uses clause

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jul 8 08:35:31 CEST 2008


On Tue, 8 Jul 2008 00:09:46 +0200
"Graeme Geldenhuys" <graemeg.lists at gmail.com> wrote:

> 2008/7/7 Vincent Snijders <vsnijders at quicknet.nl>:
> > To support package, which only do registration, like for example the
> > jpeg reader (not used atm). It registers its reader in the
> > intialization section of one the units in the package, but is not
> > used anywhere in the application further on.
> 
> Surely there must be a smarter way for Lazarus to know when to include
> or not include the package unit into a project. I just tested  Philip
> Hess's theory and he is 100% correct.

The IDE adds the package to the uses section of the program *once* and
only for the convenience of the programmer. If he don't
like it, he can remove it. Just like any unit or CreateForm statement,
that the IDE adds too.


>[...]
> As far as I know, a Lazarus Package contains a flag or something to
> say it's got a Register() function. In that case include the package
> unit in the uses clause. If the packages doesn't contain a Register()
> function, exclude it from the uses clause!

The Register procedures are not called by this.
As Vincents already said:
It's added to call the initialization sections.

 
> When deploying apps over the internet every byte counts!  No need to
> follow Microsoft's idea of creating every application with bucket
> loads of bloat.

Then decide what initializations you needs and remove the unneeded.
But keep in mind, if the package changes, you have to add/remove/rename
units yourself.

And with dynamic libraries you have to add the package anyway (When
eventually FPC supports them).

Mattias



More information about the Lazarus mailing list