[fpc-pascal] Ideas for namespace implementation
graemeg.lists at gmail.com
Mon Jul 26 12:14:26 CEST 2010
Op 2010-07-26 11:18, Sven Barth het geskryf:
> Yes, FPC is free and examples where an older version of FPC is needed
> can only be constructed artificially, but the Delphi case still holds.
> E.g. tiOPF supports Delphi besides FPC.
> I don't know the unit structure of tiOPF but suppose you have a unit
> "utils" that once conflicted with a Delphi unit and was renamed to eg.
In the case of tiOPF, it already prefixes all units with 'ti' and all
classes with 'Tti'. The same as what fpGUI does. This reduces the chances
of conflicts, so such code can stay the same, especially if that code is
used both under Delphi and FPC.
My suggestion of namespaces is purely for FPC and FPC compatible code -
*not* Delphi. Why, because Delphi namespace support already exists, and
will not be implemented as such in FPC. So lets leave cross-compiler
projects out of the discussion, because they are a "special" case with
> Now FPC introduces the new namespace system and you'd like to jump the
> train and make tiopf "namespace aware". Now you rename the "tioutils"
> unit again to "utils" and set the prefix to "tiopf".
For FPC only projects, that would be fine with me, and those projects would
make a final release before the unit name change (for users that want
compatibility without namespaces support). Any future development can then
take advantage of namespaces and more logical unit names without ugly prefixes.
Just to show how ugly unit names look with prefixes.
tiUtils.pas vs tiutils.pas vs utils.pas
Under OSes that have filesystems that are case sensitive (like under
Linux), the norm is to use lowercase filenames. But with prefixes, it makes
such unit names hard to read, and mixing cases make unit names inconsistent
and prone to errors. Whereas, if you where free to use a simple unit name
without prefixes, you get easy to read and consistent lowercase names.
- Graeme -
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
More information about the fpc-pascal