[fpc-devel] Re: [fpc-pascal] Re: Ideas for namespace implementation
Sven Barth
pascaldragon at googlemail.com
Mon Jul 26 18:41:01 CEST 2010
On 26.07.2010 18:29, Marcos Douglas wrote:
> On Mon, Jul 26, 2010 at 1:23 PM, Sven Barth<pascaldragon at googlemail.com> wrote:
>> On 26.07.2010 18:13, Marcos Douglas wrote:
>>>
>>> On Mon, Jul 26, 2010 at 12:18 PM, Martin<fpc at mfriebe.de> wrote:
>>>>
>>>> [snip]
>>>> In fact if the existing
>>>> uses Foo in 'dir';
>>>>
>>>> could be extended to allow a package or similar
>>>> uses Foo in 'LCL'
>>>>
>>>> and an alias directive would be introduced, then it was all solved too
>>>>
>>>> uses Foo in 'lcl' alias 'FooLCL', Foo in 'RTL' alias 'FooRTL'
>>>
>>> I talked about it here:
>>> http://lists.freepascal.org/lists/fpc-devel/2010-July/020699.html
>>> http://lists.freepascal.org/lists/fpc-devel/2010-July/020791.html
>>> http://lists.freepascal.org/lists/fpc-devel/2010-July/020856.html
>>> http://lists.freepascal.org/lists/fpc-devel/2010-July/020934.html
>>
>> Not exactly. Yours is a bit different:
>>
>> uses
>> Foo in 'whereever/the/lcl/dir/is' as FooLCL,
>> Foo in 'whereever/the/rtl/dir/is' as FooRTL;
>>
>> The idea of Martin's concept is to define "aliases" for the search paths as
>> well so that you can change them by configuration or command line. So you
>> wouldn't need to check whether your path to the e.g. the LCL is the same as
>> on Martin's computer or mine.
>>
>> Whether we use "as" or "alias" and a string or an identifier for the unit
>> alias is not that an important topic.
>
> Okay, but Martin's gave us an example: uses Buttons in 'LCL'
> ...and if I have a buttons.pas too?
>
> Will be like that?
> uses
> buttons in 'LCL', buttons {my buttons};
>
> The classes/functions/etc will be depends what unit was declared for last?
This will generate a compiler error, because you can't have two units
with the same name in a uses clause (to be exactly: both uses-clauses of
an unit). You must use an alias for at least one of them. Maybe it
should be defined so that it's only usable with the "in"-directive.
E.g.:
uses
buttons in 'lcl' as lclbuttons,
buttons;
is valid while the following is not:
uses
buttons in 'lcl',
buttons as lclbuttons;
Regards,
Sven
More information about the fpc-devel
mailing list