[fpc-pascal] Re: [Bulk] Re: Namespaces Support

Marcos Douglas md at delfire.net
Sun Nov 3 16:27:59 CET 2013


On Sun, Nov 3, 2013 at 12:06 AM, Dmitry Boyarintsev
<skalogryz.lists at gmail.com> wrote:
> On Sat, Nov 2, 2013 at 12:19 PM, Marcos Douglas <md at delfire.net> wrote:
>>
>> On Sat, Nov 2, 2013 at 12:32 PM, Dmitry Boyarintsev
>> <skalogryz.lists at gmail.com> wrote:
>> >
>> > On Sat, Nov 2, 2013 at 6:55 AM, Marcos Douglas <md at delfire.net> wrote:
>>
>> This works only if you don't want use StrUtils of your project and,
>> IMHO, this is more complex solution. You will need to tell the
>> compiler which unit of your project that compiles using an unit in
>> another place that uses the same unit name you already uses in your
>> project.
>
> Not each unit. The search priority can be adjusted for a directory (3d party
> library)
>
>>
>> The "rules" that I proposed are:
>> 1- Sources in the same directory and/or own tree are compiled using
>> the "real names" of units.
>> 2- Sources in another tree are (optional) compiled using an "alias".
>> These alias are used as a prefix to real names of units.
>
> I guess, you need to define "in the same" directory. Is it "the same" to a
> project or to a unit?
> If to "a unit" then it breaks the compiler backward compatibility.

Wrong. Do not breaks the compiler backward compatibility.
I said " in the same directory and/or own tree", ie, in the same
directory and subdirectories. For these cases, the compiler do not
need changes.

> So, how  to handle the following case?
>
> /program/unit1.pas (uses TheLib.StrUtils)
> /program/unit2.pas (uses StrUtils from program)
> /program/StrUtils.pas
> /lib/StrUtils.pas
> /otherlib/otherlibunit.pas (depends on "lib" StrUtils)
>
> So how would you "otherlibunit" to be using TheLib.StrUtils? From what I can
> understand (following rule #2), you need to modify "otherlibunit.pas" and
> change "uses StrUtils" to "uses TheLib.StrUtils"

First, if you have a lib that have dependencies to another lib, you
have to provide all sources together -- in the same directory or
subdirectories.  For this case just use the rule #1.
But, if you did not provide the sources for the other lib, the user
will need to define the "ALIAS" to the lib that have dependencies
before compile it (package). For this case use the rule #2.

Regards,
Marcos Douglas



More information about the fpc-pascal mailing list