Re: Ahead of "main"?
- From: Chris Dollin <eh@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Apr 2007 06:00:41 GMT
Malcolm McLean wrote:
Some early versions of C had local functions, declared within the function
that called them. The idea never caught on, and it is now not possible to
declare functions within main.
I'm not sure /exactly/ what you're saying; but if I read you
properly, what you're saying is false.
To the best of my knowledge, no "early" versions of C had local
functions, that is, functions /defined/ inside other functions.
(I don't count BCPL as an early version of C.)
Again to the best of my knowledge, /all/ versions of C allow you
to /declare/ -- not define -- (external) functions inside functions.
Old C also had no prototypes.
Yes (where "Old" means "pre-Standard", for a useful value of "had").
So if you put functions in reverse order of
hierarchy, the compiler could do additional checking of arguments.
Whatever the order you used, the compiler "could" do such checking.
In practice it didn't: one used "lint".
Nowadays we should prototype all functions,
Not true if by "prototype" you mean "declare with a prototype"
rather than "define using typed-argument syntax".
so it doesn't matter where
main() is placed, though obviously it should be either the first or the
last function for readbility.
I'm not sure about that last: it's not /obvious/, even if it's
true.
--
Prototypical Hedgehog
Meaning precedes definition.
.
- References:
- Ahead of "main"?
- From: mdh
- Re: Ahead of "main"?
- From: Malcolm McLean
- Ahead of "main"?
- Prev by Date: Re: Ahead of "main"?
- Next by Date: Re: gets() is dead
- Previous by thread: Re: Ahead of "main"?
- Next by thread: Re: Ahead of "main"?
- Index(es):
Relevant Pages
|