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

Dmitry Boyarintsev skalogryz.lists at gmail.com
Tue Oct 29 21:05:12 CET 2013


On Tue, Oct 29, 2013 at 3:50 PM, Marcos Douglas <md at delfire.net> wrote:

> Yes, works... but the language allow hide the unit name and nobody
> uses unit name as an identifier in 99% of cases, Am I right? So,
> problems can be happen.
>
> From my experience I'd say no.
I actually had to use the explicit unit name in probably 2% of the code.
Back from Delphi days: some of the functions between WinAPI (windows.pas)
and VCL (sysutils.pas) are actually using the same name.
So specifying the exact unit name is required to get the code compiled
properly.
There were some collisions on MacOSX (carbon) type names with LCL type
names.
So it's not that unrare thing to happen.

And as you've given example above. If I'm writing a unit that uses two
separate units with the same identifiers reused, I'd recommend to specify a
unit name explicitly. (Just not to rely on a compiler doing it right for
you).
uses
  windows, graphics;

var
  wb : Windows.TBitmap;
  gb : Graphics.TBitmap.

or

uses
  windows, graphics;

type  // declare once, use everywhere
  TWindowsBitmap = Windows.TBitmap;
  TGraphicsBitmap = Graphics.TBitmap;


var
  wb : TWindowsBitmap;
  gb : TGraphicsBitmap.

thanks,
Dmitry


On Tue, Oct 29, 2013 at 3:51 PM, Dmitry Boyarintsev <
skalogryz.lists at gmail.com> wrote:

> On Tue, Oct 29, 2013 at 8:02 AM, Marcos Douglas <md at delfire.net> wrote:
>
>>  You didn't understand.
>> The namespace we talk about is like a "dinamic namespace". The
>> programmer can choose which "names" he will use in your projects when
>> these projects are using third-party frameworks.
>> In Java, eg, you can change the path of frameworks, changing the
>> "namespace", without change the original sources.
>>
> I thought I did, but named it differently.
> Isn't what you're trying to explain is suggestion #3 at this page?
> http://wiki.freepascal.org/Namespaces
>
> Instead of modifying the code (i.e. by switching to namespaces)
> You would like to give then compiler a hint what unit should be used when
> compiling a unit.
>
> In other words, you'd like to unit-specific -Fu, that should override the
> project -Fu.
> Right? or am I still misunderstanding.
>
> thanks,
> Dmitry
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20131029/ab7c50da/attachment.html>


More information about the fpc-pascal mailing list