473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Ask an old kerword "entry"

Hi all,

It is a history question.

Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.

Doea any one know how to use it, before?
Thanks

Apr 2 '07 #1
10 4134
On 2 Apr, 10:11, Lung.S...@gmail.com wrote:
Hi all,

It is a history question.

Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.

Doea any one know how to use it, before?
The original Kernighan and Ritchie book says that it was reserved as a
keyword, but not implemented by any compiler - they don't give any
more detail. They presumably had a feeling that they might need such a
keyword, and some idea what they would use it for, but the need never
actually materialized.

Apr 2 '07 #2
ma**********@pobox.com writes:
On 2 Apr, 10:11, Lung.S...@gmail.com wrote:
>It is a history question.

Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.

Doea any one know how to use it, before?

The original Kernighan and Ritchie book says that it was reserved as a
keyword, but not implemented by any compiler - they don't give any
more detail. They presumably had a feeling that they might need such a
keyword, and some idea what they would use it for, but the need never
actually materialized.
I think some versions of Fortran have an "entry" keyword, allowing
more than one entry point to be specified for a subroutine. (I don't
know whether this survived into modern Fortran.) For example,
in pseudo-C:

void foo(void)
{
printf("FOO ");
entry bar:
printf("BAR\n");
}

Calling foo() would print "FOO BAR"; calling bar() would print "BAR".
(Presumably there would be some declaration syntax to make the name
"bar" visible to the caller.)

I've seen a more realistic example that combines sin() and cos() into
a single function. Calling it through the primary entry point would
adjust the argument; the remainder of the function, after the
secondary entry point, would compute the sine of the (possibly
adjusted) argument, which happens to be the cosine of the unadjusted
argument.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 2 '07 #3
Keith Thompson wrote:
I think some versions of Fortran have an "entry" keyword, allowing
more than one entry point to be specified for a subroutine. (I don't
know whether this survived into modern Fortran.)
ENTRY is part of modern Fortran (at least through F95). F77 relaxed the
restrictions on its use, making it even more common than F66. The
current syntax has added a RESULT clause that it did not have earlier.

F2C and g77 both compiled a separate copy for each entry, so your
pseudo-C example, if it were the equivalent Fortran,
void foo(void)
{
printf("FOO ");
entry bar:
printf("BAR\n");
}
would be compiled as it it were written
void foo(void)
{
printf("FOO ");
printf("BAR\n");
}
void bar(void)
{
printf("BAR\n");
}
Apr 2 '07 #4
On Apr 2, 8:46 pm, Martin Ambuhl <mamb...@earthlink.netwrote:
Keith Thompson wrote:
would be compiled as it it were written
void foo(void)
{
printf("FOO ");
printf("BAR\n");
}
void bar(void)
{
printf("BAR\n");
}
That's crazy! Why not one function, an extra argument (or global
variable), and an if or switch at the start of the function?

Apr 2 '07 #5
Fr************@googlemail.com writes:
On Apr 2, 8:46 pm, Martin Ambuhl <mamb...@earthlink.netwrote:
>Keith Thompson wrote:
would be compiled as it it were written
void foo(void)
{
printf("FOO ");
printf("BAR\n");
}
void bar(void)
{
printf("BAR\n");
}

That's crazy! Why not one function, an extra argument (or global
variable), and an if or switch at the start of the function?
(There's some context missing here; I didn't write any of the quoted
material.)

The use of the "entry" keyword, assuming the compiler doesn't
duplicate code as described above, allows a small improvement in code
size and speed. You don't have the overhead of passing the extra
argument or of doing a test on entry, and you don't have two copies of
what might be a substantial amount of code. There have been
situations where that might be significant, such as early Fortran
systems, where using Fortran (or any high-level language) was a
sometimes controversial alternative to hand-coded assembly language
(or even machine language).

The functionality that "entry" would provide is something that can be
expressed straightforwardly in assembly language; that's probably why
it was included in Fortran.

The implementation that Martin describes might just have been the
easiest way to implement it, for the purpose of supporting old code
that depended on it (but that, if it's running on modern hardware,
isn't affected by the limitations that existed when it was first
written).

Note, however, that the authors of the C standard apparently agreed
with you (and with me) that it's not worthwhile; the "entry" keyword
was never implemented and did not survive past K&R1.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Apr 2 '07 #6
In article <ln************@nuthaus.mib.org>,
Keith Thompson <ks***@mib.orgwrote:
The functionality that "entry" would provide is something that can be
expressed straightforwardly in assembly language; that's probably why
it was included in Fortran.
....and C--! :)

(See <http://www.cminusminus.org/extern/man2.pdf>, Section 6.7.)
Lauri
Apr 3 '07 #7
Keith Thompson wrote:
ma**********@pobox.com writes:
>On 2 Apr, 10:11, Lung.S...@gmail.com wrote:
>>It is a history question.

Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.

Doea any one know how to use it, before?
The original Kernighan and Ritchie book says that it was reserved as a
keyword, but not implemented by any compiler - they don't give any
more detail. They presumably had a feeling that they might need such a
keyword, and some idea what they would use it for, but the need never
actually materialized.

I think some versions of Fortran have an "entry" keyword, allowing
more than one entry point to be specified for a subroutine. (I don't
know whether this survived into modern Fortran.) For example,
in pseudo-C:

void foo(void)
{
printf("FOO ");
entry bar:
printf("BAR\n");
}
The 'bar' function here has no prototype. How is it
supposed to handle parameters?

You can use the following, which gives you the same functionality

void foo(void)
{
printf("FOO ";
bar();
}
void bar(void)
{
printf("BAR\n");
}

which should work on all current C compilers, and does
exactly what you are trying to do. And if you later
need to create a "FUU BAR" message, you can just add

void fuu(void)
{
printf("FUU ";
bar();
}

Many compilers can optimize the jump from foo to bar
using a "jump" instead of a "call", automatically
dealing with any parameters passed.
Calling foo() would print "FOO BAR"; calling bar() would print "BAR".
(Presumably there would be some declaration syntax to make the name
"bar" visible to the caller.)

I've seen a more realistic example that combines sin() and cos() into
a single function. Calling it through the primary entry point would
adjust the argument; the remainder of the function, after the
secondary entry point, would compute the sine of the (possibly
adjusted) argument, which happens to be the cosine of the unadjusted
argument.
You can handle it as above, or, you can deal with it
as a #define or an inline function

#define cos(x) = sin((x) + PI/4)

(or whatever the proper transformation is.)

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
May 2 '07 #8
Kevin Handy <kt*@srv.netwrites:
Keith Thompson wrote:
>ma**********@pobox.com writes:
>>On 2 Apr, 10:11, Lung.S...@gmail.com wrote:
It is a history question.

Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.

Doea any one know how to use it, before?
The original Kernighan and Ritchie book says that it was reserved as a
keyword, but not implemented by any compiler - they don't give any
more detail. They presumably had a feeling that they might need such a
keyword, and some idea what they would use it for, but the need never
actually materialized.
I think some versions of Fortran have an "entry" keyword, allowing
more than one entry point to be specified for a subroutine. (I don't
know whether this survived into modern Fortran.) For example,
in pseudo-C:
void foo(void)
{
printf("FOO ");
entry bar:
printf("BAR\n");
}
The 'bar' function here has no prototype. How is it
supposed to handle parameters?
I don't know. The snippet above, as I said, is pseudo-C, intended to
represent an old Fortran feature that I'm not very familiar with. But
since the "entry" keyword in C died before the ANSI standard was
written, presumably prototypes wouldn't have been required.

But if the feature were to be implemented in C, the obvious semantics
would be that bar() would share the same prototype as foo().
You can use the following, which gives you the same functionality
[snip]
Many compilers can optimize the jump from foo to bar
using a "jump" instead of a "call", automatically
dealing with any parameters passed.
Certainly. The "entry" keyword, as I understand it, was intended to
support a particular micro-optimization, something that's probably
easy to implement in assembly language but difficult to express
directly in C.

[...]
>I've seen a more realistic example that combines sin() and cos() into
a single function. Calling it through the primary entry point would
adjust the argument; the remainder of the function, after the
secondary entry point, would compute the sine of the (possibly
adjusted) argument, which happens to be the cosine of the unadjusted
argument.

You can handle it as above, or, you can deal with it
as a #define or an inline function

#define cos(x) = sin((x) + PI/4)

(or whatever the proper transformation is.)
Yes, the "entry" keyword is unnecessary; that's why it's no longer in
the language. I was merely trying to explain it; I certainly wasn't
advocating it.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
May 2 '07 #9
On Wed, 02 May 2007 13:02:11 -0700, Keith Thompson <ks***@mib.orgwrote:
>Kevin Handy <kt*@srv.netwrites:
>Keith Thompson wrote:
>>ma**********@pobox.com writes:
On 2 Apr, 10:11, Lung.S...@gmail.com wrote:
It is a history question.
>
Recently, I read the book "C A reference manual, third edition".
In this book, it list all C language keyword, and one is "entry".
I know it is omitted from ANSCI C, but I hope I can find any data
about it.
>
Doea any one know how to use it, before?
The original Kernighan and Ritchie book says that it was reserved as a
keyword, but not implemented by any compiler - they don't give any
more detail. They presumably had a feeling that they might need such a
keyword, and some idea what they would use it for, but the need never
actually materialized.
I think some versions of Fortran have an "entry" keyword, allowing
more than one entry point to be specified for a subroutine. (I don't
know whether this survived into modern Fortran.) For example,
in pseudo-C:
void foo(void)
{
printf("FOO ");
entry bar:
printf("BAR\n");
}
The 'bar' function here has no prototype. How is it
supposed to handle parameters?

I don't know. The snippet above, as I said, is pseudo-C, intended to
represent an old Fortran feature that I'm not very familiar with. But
since the "entry" keyword in C died before the ANSI standard was
written, presumably prototypes wouldn't have been required.

But if the feature were to be implemented in C, the obvious semantics
would be that bar() would share the same prototype as foo().
>You can use the following, which gives you the same functionality
[snip]
>Many compilers can optimize the jump from foo to bar
using a "jump" instead of a "call", automatically
dealing with any parameters passed.

Certainly. The "entry" keyword, as I understand it, was intended to
support a particular micro-optimization, something that's probably
easy to implement in assembly language but difficult to express
directly in C.

[...]
>>I've seen a more realistic example that combines sin() and cos() into
a single function. Calling it through the primary entry point would
adjust the argument; the remainder of the function, after the
secondary entry point, would compute the sine of the (possibly
adjusted) argument, which happens to be the cosine of the unadjusted
argument.

You can handle it as above, or, you can deal with it
as a #define or an inline function

#define cos(x) = sin((x) + PI/4)

(or whatever the proper transformation is.)
That, perhaps, is an illustration of the benefits of "entry". The proper
transformation can be encapsulated in the routine body.
>
Yes, the "entry" keyword is unnecessary; that's why it's no longer in
the language. I was merely trying to explain it; I certainly wasn't
advocating it.
It is not so much that it is unnecessary as it is that it inconsistent with
how C is typically implemented. Languages with multiple entry point
routines usually presuppose that the data for a call is in a fixed location
rather than on a stack. The original fortran was like that; recursion was
impossible.

May 2 '07 #10
Keith Thompson <ks***@mib.orgwrote:
But if the feature were to be implemented in C, the obvious semantics
would be that bar() would share the same prototype as foo().
I suppose it's obvious if you've never programmed in Fortran 77.
However - for reference:

http://www.fortran.com/F77_std/rjcnf-15.html#sh-15.7

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net
May 3 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
0
by: BW | last post by:
Please ignore the rest of the code, except for the highlighted part (or the line 'ent1=Entry(topf, width=25)' to line 'ent1.insert(INSERT, wrong, if you cannot see the color). You can copy this into...
3
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim...
5
by: Jeff Sandler | last post by:
I have a web page. It uses JavaScript to test the user's input before sending it to the server. It frequently tests using isNaN() with some very interesting results. The statements in question...
6
by: Alan Silver | last post by:
Hello, I have a page that displays a data list with info from a database. The grid has the usual stuff, edit, update, delete etc. Below this I have a section where they can add a new entry to...
4
by: Jim in Arizona | last post by:
I'm new to aspnet with only limited experience with classic asp. Since I'm on a domain and all users are authenticated. In the past using classic asp I used request.servervariables("auth_user") to...
15
by: Brady Love | last post by:
I am currently working an an app that will post and edit blogs on blogger. Right now I have it so I can recive a list of the blogs and the content of those blogs using Atomizer. This is my first...
3
by: ElBeardo | last post by:
Hello, I´m new to Python.. so this is a newbee question. I´d like to put the value enterd in the entryfield in a variable. I´m trying to build a calculator with python and TKinter, coding it in...
0
by: Curious | last post by:
Hi, I try to set up debugging environment in Visual Studio 2003. So I open the Properties of the project and select "Debugging". I'll need to at first enter "C:\Program Files\AutoTrade\MyTools...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.