[fpc-pascal] Looking for JavaScript component on FPC

Michael Van Canneyt michael at freepascal.org
Fri Apr 3 11:39:33 CEST 2015



On Fri, 3 Apr 2015, Graeme Geldenhuys wrote:

> On 2015-04-03 08:09, Michael Van Canneyt wrote:
>> To be sure, it was introduced to be delphi compatible.
>> Whether namespaces are 'modern','advanced' or not is a matter of debate.
>> In the end (at the assembler level) it's all a flat namespace anyway.
>
> But namespaces are functional in Delphi - not just cosmetic. So are you
> saying that FPC doesn't have the same functional ability as Delphi when
> it comes to namespaces?
>
> The following is how somebody explained Delphi namespaces to me:
>
> In stead of having directories like this with the same unit names and
> having to use IFDEF's and play with unit paths...
>
> /GUI/VLC/tiMediators.pas
> /GUI/VLC/tiListMediators.pas
> /GUI/LCL/tiMediators.pas
> /GUI/LCL/tiListMediators.pas
> /GUI/FMX/tiMediators.pas
> /GUI/FMX/tiListMediators.pas
>
> ...instead you can flatten the directory hierarchy to simply a single
> GUI directory as follows:
>
> /GUI/VLC.tiMediators.pas
> /GUI/VLC.tiListMediators.pas
> /GUI/LCL.tiMediators.pas
> /GUI/LCL.tiListMediators.pas
> /GUI/FMX.tiMediators.pas
> /GUI/FMX.tiListMediators.pas
>
>
> That way we don't need $IFDEFs or special Unit Search Paths, just
> specify "FMX" or "VCL or "LCL" in the Project Unit Scope names list.

you just change one option -Fu/GUI/LCL to 2: -Fu/GUI -NLCL
I don't see much added value in that.

Additionally I like my files in separate directories.

It's all a matter of preference.

As for ifdefs:
The units MUST have the same interface or else the IFDEFS pop up anyway.
So nothing is gained with namespaces (in this regard). 
We do the above since 20 years in the RTL. The LCL has macros for it.

Don't get me wrong, I have nothing against namespaces.
I just don't think they are the "sliced bread of IT" as some do. 
Their usefulness in pascal is IMHO hugely overrated.

> You then simply refer to those units in your uses clause by using:
>
>  uses
>    tiMediator, tiListMediator;
>
> The compiler will then know which unit to use because of the scope you
> specified in the project.
>
> I take it FPC doesn't support this then?

To my knowledge, it does ?

Michael.


More information about the fpc-pascal mailing list