Re: changing module files
From: Dave Thompson (david.thompson1_at_worldnet.att.net)
Date: 12/25/03
- Next message: emammendes: "Re: intel 8.0 and Matlab 6.5 - mex files"
- Previous message: David Frank: "Re: Error reading unformatted file"
- In reply to: John Lansberry: "Re: changing module files"
- Next in thread: Richard Maine: "Re: changing module files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 25 Dec 2003 01:45:28 GMT
On Wed, 17 Dec 2003 08:51:49 -0500, "John Lansberry"
<john.lansberry@jhuapl.edu> wrote:
<snip>
> For me, the fact that modules must be compiled is a major obstacle to object
> oriented (OO) programming. That is, objects of different classes
> (definitions of which are encapsulated in modules) cannot USE each other
> (directly or indirectly).
>
> C++ header files avoid that problem, because header files only declare the
> INTERFACE to class member functions. Whether any such member function is
> actually defined somewhere is not determined until compile time.
This is not entirely correct. If you want inline(able) definitions of
methods, they must be defined in the declaration used by callers,
which for a normal source organization is the header file. And the
class declaration includes all data members and methods (and thus
vtable layout) even those to which external access is not allowed.
> Hence, if
> the header file is wrong (provides the wrong list of arguments to a
> function), you won't know about it until link time in C++.
The implementation should always #include the interface specification
used by clients, and any *mismatch* of a method implementation will be
caught at compile time. A *missing* implementation will only be caught
at link -- or for the few automatically synthesized by the compiler,
like default constructor and assignment, not at all. For free routines
mismatch won't be caught until link, because it will just look like an
overload. And (accidental) use of the wrong declaration of a class, or
other data structure, such as by using the wrong include directories,
generally won't be caught at all.
> I'm no fan of
> header files. I think they are ugly and prone to errors. Plus, you need to
> understand and be comfortable with all of the preprocessor macros. IMHO,
> requiring the use of a preprocessor to get something to compile and link
> represents a fundamental flaw in the design of the language.
No macros are needed by C or C++ header files particularly except
(usually) "include guards" to prevent (unnecessarily illegal)
duplicate declarations if the same header is #include'd more than
once, such as for multiple inheritance paths; these are simple and can
be treated almost as noise, like IMPLICIT NONE.
C++ code and even more so C does tend to use macros a lot, and they
don't fit into the language very well, but this is true of source code
and even build commands/files as well as header files.
Certainly source inclusion, while more general, is less precise than a
true module/package/whatever system, whether with separate interfaces
as in Ada or not as in Fortran or Java, but I think 'fundamental flaw'
is going a bit far.
- David.Thompson1 at worldnet.att.net
- Next message: emammendes: "Re: intel 8.0 and Matlab 6.5 - mex files"
- Previous message: David Frank: "Re: Error reading unformatted file"
- In reply to: John Lansberry: "Re: changing module files"
- Next in thread: Richard Maine: "Re: changing module files"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|