Re: simple vs complex languages

Dave Thompson <>
5 Jun 2003 23:20:05 -0400

          From comp.compilers

Related articles
[34 earlier articles]
Re: simple vs complex languages (2003-06-03)
Re: simple vs complex languages (Jan C.=?iso-8859-1?Q?Vorbr=FCggen?=) (2003-06-05)
Re: simple vs complex languages (2003-06-05)
Re: simple vs complex languages (2003-06-05)
Re: simple vs complex languages (David Chase) (2003-06-05)
Re: simple vs complex languages (Yiorgos Adamopoulos) (2003-06-05)
Re: simple vs complex languages (Dave Thompson) (2003-06-05)
Re: simple vs complex languages (Lex Spoon) (2003-06-05)
Re: simple vs complex languages (2003-06-08)
Re: simple vs complex languages (2003-06-08)
Re: simple vs complex languages (Lex Spoon) (2003-06-20)
| List of all articles for this month |

From: Dave Thompson <>
Newsgroups: comp.compilers
Date: 5 Jun 2003 23:20:05 -0400
Organization: AT&T Worldnet
References: 03-04-095 03-05-013 03-05-184 03-05-212
Keywords: design, C
Posted-Date: 05 Jun 2003 23:20:05 EDT

On 29 May 2003 03:26:59 -0400, (Ziv Caspi)

> On 24 May 2003 20:07:47 -0400, Jack Crenshaw <>
> wrote:
> [...]
> >C used to allow functions to be declared later in the code than the
> >calls to them. It doesn't, anymore. Today we use prototypes, which is
> >a whole lot better deal. Pascal also allows prototypes -- otherwise
> >one could never do forward references. So why is one language
> >superior to the other in this respect? How is it that Pascal forces
> >you to "write .. bottom-up," where C does not???
> [...]

First, note that 'prototype' in C does not actually mean, as people
frequently use it mean, a separate/forward declaration. It means a
function declaration *or* definition in the new=C++ format rather than
the old K&R1 format. It is true that C99 (though not yet widely
implemented, to put it mildly) requires functions to be declared
before use, either by their definition or separately, where C89 (and
K&R1) did not. C99 does not require that these definitions or
(forward) declarations be prototypes; you can still use K&R1 format,
though it is almost never sensible to do so.

> >[In the versions of Lisp that I know, a function doesn't have to be
> >declared or defined until its called. That can make development a lot
> >easier. -John]
> It's interesting to note that the language C stole prototypes from
> (C++) actually does not require prototypes (or any other kind of
> forward declarations) when it comes to class members, probably because
> class declarations cannot span compilation units.

I'm not sure exactly what this was supposed to mean, but I think it's
wrong. Assuming we are talking only about member functions (not
data), C++ requires all member functions to be declared within the
class definition; they can either be defined inline in the class
definition, or defined separately, after the class definition, and
usually in a different source file (i.e. the class defn is in a .h and
the member function defns are in a .C) in which case the declaration
in the class definition is a (required) forward declaration. Or
member functions need not be defined at all if never used; but for
virtual methods they will (on all known implementations) be referenced
by the vtable and hence "used" even if never actually called.

The (same) complete class defn must be contained in each compilation
unit (or formally translation unit, which is one source file after
preprocessing) which uses it other than as a pointer target type or to
declare an uncalled function, normally by #include'ing a .h.
The definitions of member functions (and for that matter static data
members) *can* be spread across multiple t.u.s, although this is
usually a poor design.

- David.Thompson1 at

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.