[Lazarus] Packages and units with the same name

Sven Barth pascaldragon at googlemail.com
Sat Oct 14 09:33:12 CEST 2017


Am 14.10.2017 00:03 schrieb "Marcos Douglas B. Santos via Lazarus" <
lazarus at lists.lazarus-ide.org>:
>
> On Fri, Oct 13, 2017 at 6:40 PM, Sven Barth via Lazarus
> <lazarus at lists.lazarus-ide.org> wrote:
> > On 13.10.2017 21:32, Marcos Douglas B. Santos via Lazarus wrote:
> >> [...]
> >>
> >> IMHO, would be better if packages may have just some "exported units".
> >> What do you think?
> >
> > It doesn't matter. Any symbols in a unit are mangled only locally to the
> > unit and there *can not* be two or more symbols with the same name in
> > one program. What you ask for is simply not possible.
>
> Is it not possible *today* or never?
> I don't know how the compiler works, but try to understand me:
> I would like to modularize a big program in small packages — because
> it's better than to use dll/so.
> Each one these packages will work in a bounded context. Each one may
> have a "Facade" to the main program, exposing its "interface" (classes
> and interfaces, most).
> So, the main program shouldn't know nothing about "private units" that
> belongs only for the package.
> That is encapsulation too.

I can very reasonably say that this will never be possible. It's simply how
things work on the binary level. And as I said that's also true for dynamic
packages (which are a different beast than Lazarus' packages): even if a
unit becomes part of a package it won't be touched as it can be used as
part of the package as well as directly in the application binary without
any changes.
Unit names *must* be unique inside a program (with or without packages). So
better use prefixes or dotted unit names to reduce the chance for conflicts.

Regards
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20171014/18034f30/attachment.html>


More information about the Lazarus mailing list