[fpc-devel] "Friend" classes?
drdiettrich at compuserve.de
Sat Mar 19 10:04:55 CET 2005
Ales Katona wrote:
> C++ requires "friend" only because it lacks the idea of modularity.
> Since all classes are "apart" they need some way to tell each other "I
> can use you"
> In pascal you simply put them into 1 unit.
That's why the C++ model is better, there exists no requirement to
implement related classes in a single module.
In porting C++ code to Pascal I often stumbled into circular unit
references. Then the only solution is a monster unit, that implements
all the related classes at once, where the C++ implementation can be
split into appropriate modules. Even in Java it's possible to implement
every class in a dedicated unit, regardless of class relationships, and
without a need for separate header files. That's what I call a good
Perhaps I dislike Pascal include files only because they are poorly
supported by the Delphi IDE. With better support it were possible to
split the implementation into multiple dedicated include files, which
could be thought of as implementation files, according to e.g. the
Modula model. Lazarus offers better support for included files, but
unfortunately it currently groups the types, constants etc. overview
together by the according clauses; I hope for better grouping options in
the near future, so that e.g. all types of an unit can reside in a
single group. I already considered to contribute to the Lazarus
development, but currently I have other projects with higher priority...
More information about the fpc-devel