15

I posted this question on StackOverflow, but someone commented and advised me to publish it here.

Here the terms K&R1 and K&R2 refer to a book written by the C creators about the language. K&R1 is the first edition (1978, before the standardization), and K&R2 is from 1988.

entry is a reserved identifier in K&R1, which seems to come from PL/I and FORTRAN.
Someone already posted a question about entry here, and the accepted answer said some compilers implemented it, but the K&R2 states

entry, formerly reserved but never used, is no longer reserved

Who is right ? Did the K&R2 take a shortcut because it was almost not used, and maybe it wasn't relevant for the reader ? Then, if entry has existed, which compilers did implement it ?

In their answer, the author also shared this link, but it only suggests some compilers implemented it, without giving any example though :

Some C compilers prior to the standard implemented that keyword. Since it was never part of any version of the C standard, it has no defined standardized meaning.

I asked this question by curiosity, as I'm very interested about early C.

16
  • 1
    You may want to link that question as reference. Likewise it wold be helpful for uninitiated readers to avoid/explain shortcuts like K&R1/2 - maybe even link them.
    – Raffzahn
    Commented Jan 30 at 9:28
  • 6
    Early C had a few ideas that never went anywhere; for example, operations to compute mix and max were envisioned but never fully implemented; later they were abandoned altogether. Also, strictly speaking, "implementing" a keyword might mean as little as adding the keyword to the table of reserved words and assigning a unique token to it, which would not be mentioned in any grammar rule. Any use of the keyword in any context would cause a syntax error.
    – Leo B.
    Commented Jan 30 at 10:04
  • 3
    In my Harbison & Steele (3rd edition) in 2.6 Reserved Words they do include entry with a footnote "Traditionally reserved, but omitted from ANSI C." This footnote is also used for the asm and fortran entries.
    – Jon Custer
    Commented Jan 30 at 14:27
  • 2
    False. _Bool was reserved in C89 by virtue of starting with an underscore and a capital letter, and as far as I know, this reservation stays in place even in the latest draft. Most post-C90 keywords were in fact of this form. volatile and restrict were never reserved without being given grammar productions and meaning. Commented Jan 31 at 13:24
  • 1
    @LeoB.: One of the major design goals of C was to allow someone armed with a rather simple complier, who knew what kinds of constructs would be efficient on the target platform, to end up with efficient machine code. The amount of compiler logic to support an operator which adds or subtracts a byte displacement from a pointer without affecting its type would be tiny compared with the amount required to have a compiler make complex inferences.
    – supercat
    Commented Feb 2 at 3:45

2 Answers 2

3

According to Bell Labs in 1984, no

The C Programmer's Handbook was published by AT&T Bell Laboratories in 1984. This is after the 1st edition of K&R, but before the ANSI standard and K&R 2nd edition. They claim "entry is not currently implemented by any compiler but is reserved for future use":

C Programmer's Handbook page 4

Note that "any compiler" would include those on 10 systems:

C Programmer's Handbook page 3

8

Per the document Rationale for American National Standard for Information Systems - Programming Language - C, which is an accompanying informative document to American National Standard for Information Systems - Programming Language - C (X3.159-1989):

3.1.1 Keywords
The keywords entry, fortran, and asm have not been included since they were either never used, or are not portable. Uses of fortran and asm as keywords are noted as common extensions.

(Common Extensions is section F.5 in the standard proper)

This wording is not definitive in deciding that 'entry' was 'never' used, though it certainly was not common enough to be called a common extension. We might conclude that 'asm' and 'fortran' were implemented in some compilers but not portable, which leaves only one contender for 'never used'.

Furthermore, it is difficult to see how 'entry' could be incorporated into C syntax. An entry point definition, in contemporary usage, required not only the point of entry to be noted (this could be done with some variation on label syntax), but the names and types of the formal arguments, which need not be a subset of the formal arguments of the 'normal' entry point. Some complicated rules would have to be invented as to what was in scope and what was not.

For this reason, I conclude (by deduction from available information) that 'entry' was never implemented.

21
  • 2
    As far as I am aware, there's no block-structured language with multiple entry-point routines, because of the mess that causes to scoping rules and semantics.
    – dave
    Commented Jan 31 at 23:42
  • 1
    In pseudocode: function foo(int x); ...; entry bar(float y); ... // what names are in scope at this point? Even if you class 'entry' as the start of a block, the status of 'x' is unclear. You can only resolve this by making up arbitrary rules, which cut across the clarity of nested blocks. Fine for assembler and Fortran; anathema to Algol and its descendents.
    – dave
    Commented Feb 1 at 0:28
  • 1
    C does not have the concept of "address vector", so I don't know what that is supposed to mean for C. Can you state the issue in terms known to C?
    – dave
    Commented Feb 1 at 1:15
  • 1
    That's what a 'function pointer' points to, undefined by C (contrary to common myth, it does not always point directly to the code). Any entry-supporting C compiler could define function pointers to extend to alternative entry points.
    – dave
    Commented Feb 1 at 11:32
  • 1
    Where did that concept of what a C 'entry' would be come from? My mental model is Fortran 77 ENTRY.
    – dave
    Commented Feb 2 at 2:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .