[Lazarus] Packages and units with the same name

Marcos Douglas B. Santos md at delfire.net
Sat Oct 14 23:31:34 CEST 2017


On Sat, Oct 14, 2017 at 4:33 AM, Sven Barth via Lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> 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.

My next question would be about dynamic packages... but you've already
answered me.
Thanks for all information.

Best regards,
Marcos Douglas


More information about the Lazarus mailing list