[fpc-pascal] Re: Ideas for namespace implementation

Graeme Geldenhuys graemeg.lists at gmail.com
Sun Jul 25 20:11:29 CEST 2010


On 25 July 2010 19:16, Michael Van Canneyt wrote:
>
> What unit name conflicts ? In 15 years that I work with Delphi and FPC, and
> I have use many many packages, I encountered exactly 1 conflict:

Then you are extremely lucky. I have experience stacks of unit name
conflicts in my years of programming. Have you never had the urge to
use the unit name: constants.pas? utils.pas?



> the strutils of rxlib, which conflicted with strutils introduced in a later
> version of Delphi. The RX copy was renamed to rxstrutils, and that was it.

A perfect example of the problem!
  * Compilers get preference over the easy and well descibed unit
names, while other projects must now rename there units.
  * Other projects now have to live with crappy named units with ugly prefixes.
  * can't use underscores because for some reason it is frowned appon,
so now you
    get odd looking units where the prefix ends with the same letter
as the original unit names.

Utilities functions that work on Strings - wouldn't it make sense to
have them in a unit: strutils.pas?
Currently we can't, even though the unit name perfectly describes the
function of that unit - so we have to shun from the ideal name. If we
don't, we are guaranteed to get conflicts in our projects. So now only
the "compiler" projects like Delphi or FPC my use such names - that is
crap.


> I am sorry, but I think that the seriousness of the problem is very much
> overestimated. Wanting to type rx.strutils versus rxstrutils. Really ?

And my suggestion (2) will reduce such syntax *only* when a conflict
has occured, without long unit names.


> And let us not forget: most component vendors must support older versions of
> Delphi, so they are barred from using the dotted unit name syntax anyway.

Which option (2) I suggested will also handle via a namespace compiler
parameter or the 'namespace <value>' in the unit, but declared inside
a IFDEF checking for compiler version: eg

unit utils {$IFDEF Ver2_4_x} namespace myproject {$ENDIF};
uses
  ...
end.


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list