On 14/04/13 08:59, Mattias Gaertner wrote: >>> >>> I'm curious: why do you use dots instead of for example underscores? > > Thanks. You are one of the few people who give some arguments > beside aesthetic reasons.
Someone recently explained Delphi's namespace usage to me, and gave me a valid example of this. tiOPF has unit names with the same name, but used by different GUI toolkits. eg: tiMediators.pas is used by VCL, LCL and fpGUI. Each toolkit support has there own tiMediator.pas unit. You need to change unit search paths, so the compiler knows which unit to use. Anyway, recently somebody added FireMonkey support for the tiOPF mediators (Model-GUI-Mediator design pattern), but found an issue with threading. The tiOPF has a tiThread.pas unit, but FireMonkey's threading works differently. So instead of littering the tiThread.pas code with IFDEF's, the developor simply duplicated the units (yeah, not too great), but then added the "FMX" namespace to that unit. eg: tiThread.pas FMX.tiThread.pas Now the developer could simply use tiThread in the uses clause of FireMonkey code, because his FireMonkey apps define the FMX namespace, so the compiler and IDE knew which tiThread unit to use. No IFDEF's required! --------------[ forward ]----------------- /GUI/FMX/tiMediators.pas /GUI/FMX/tiListMediators.pas It involved a bit of mucking around with some of the mediator view classes. eg. TComboBox works differently. A couple of other units didn't compile, so I duplicated them and added the FMX. namespace… /Core/FMX.tiThreads.pas /GUI/FMX.tiGUIConstants.pas That way we don't need $IFDEFs, just "FMX" in the project unit scope names list. In fact, I don't recall seeing a compiler directive to distinguish FMX and VCL. Units are often given the prefix. Eg. Vcl.Forms and FMX.Forms. ----------------[ end ]------------------- PS: I'm not sure if Free Pascal already supports such namespace / unit scope yet. Regards, - Graeme - -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus