473,769 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

call() and return()

I just read §2.11.3 of D&E, and I have to say, I'm quite puzzled by what it
says.

http://java.sun.com/docs/books/tutor...y/syncrgb.html
<shrug>
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Dec 15 '06
46 3861
Steven T. Hatton wrote:
>>Back to the original topic. After having 25 years to reflect upon the
matter, do you believe omitting call() and return() from C++ was the
right _design_ choice?
Have you considered that if it were a big demand for that feature several
compilers were already implemented it as extension?
Perhaps, but how long did quaternions languish as an academic curiosity
before someone realize they had a use in 3D graphics?
I suppose that "someone" put his ideas at work, instead of telling other
people "I have an intuition about quaternions, the graphics library writers
must consider using it".
There are many good ideas sitting on bookshelves,
Yes, there are plenty of ideas, and people elaborate new ones every day.
I have to say, however, that my intuition is very strongly in favor of
their usefulness.
But is hard that other people start to work in that field just by your
intuition. People usually spend his time with his own intuitions and ideas.

--
Salu2
Dec 17 '06 #31
Julián Albo wrote:
Steven T. Hatton wrote:
>>>Back to the original topic. After having 25 years to reflect upon the
matter, do you believe omitting call() and return() from C++ was the
right _design_ choice?
Have you considered that if it were a big demand for that feature
several compilers were already implemented it as extension?
Perhaps, but how long did quaternions languish as an academic curiosity
before someone realize they had a use in 3D graphics?

I suppose that "someone" put his ideas at work, instead of telling other
people "I have an intuition about quaternions, the graphics library
writers must consider using it".
Someone did, well, in a sense. He wrote a book explaining the idea, and a
lot of other people used it.
>There are many good ideas sitting on bookshelves,

Yes, there are plenty of ideas, and people elaborate new ones every day.
>I have to say, however, that my intuition is very strongly in favor of
their usefulness.

But is hard that other people start to work in that field just by your
intuition. People usually spend his time with his own intuitions and
ideas.
As far as I know, there is only one person in the world who has hands-on
experience working with this design. I asked for his opinion. Not yours.

--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Dec 18 '06 #32
Steven T. Hatton wrote:
Perhaps, but how long did quaternions languish as an academic curiosity
before someone realize they had a use in 3D graphics? There are many good
ideas sitting on bookshelves, either waiting from someone to come along and
realize their value, or for someone who recognizes their value to gain the
skills and resources necessary to make use of them.
Quaternions have had a known use long before 3D graphics. They are used
in rocket and missile guidance algorithms.
Dec 18 '06 #33
Stroustrup: When I designed C with Classes and C++, I was very keen on the
idea that a class defined the environment in which the code of its member
functions operate (I still am). This led to the notion of constructors that
establish that environment (invariant) and acquire the resources needed.
Destructors reverse that process (releasing resources). These ideas are at
the root of the design of exceptions and resource management. For example,
see the new Appendix E: "Standard-Library Exception Safety" of The C++
Programming Language.[3] That appendix can be downloaded from my home
pages.[4]

Based on that line of thinking, C with Classes also allowed you to define a
call() function that was called before entry into a member function and a
return() function that was called after exit from a member function. The
call()/return() mechanism was meant to allow a programmer to manage
resources needed for an individual member function invocation. This allowed
me to implement monitors for the first task library. A task's call()
grabbed a lock and its matching return() released the lock. The idea came
partly from Lisp's :before and :after methods. However, the notion wasn't
perfectly general -- for example, you couldn't access arguments for a
member function call from call(). Worse, I completely failed to convince
people of the usefulness of this notion, so I removed call() and return()
when I defined C++.
</quote>

The last sentence is what has me baffled.
why do we need it as a standard mechanism? Cant we have the call to
call() at the begining of every member function and return() before
every return? May be something like
#define RETURN returnf(); return

Dec 18 '06 #34
Steven T. Hatton wrote:
As far as I know, there is only one person in the world who has hands-on
experience working with this design. I asked for his opinion.
.... and ignored it.

--
Salu2
Dec 18 '06 #35
king wrote:
>Stroustrup: When I designed C with Classes and C++, I was very keen on
the idea that a class defined the environment in which the code of its
member functions operate (I still am). This led to the notion of
constructors that establish that environment (invariant) and acquire the
resources needed. Destructors reverse that process (releasing resources).
These ideas are at the root of the design of exceptions and resource
management. For example, see the new Appendix E: "Standard-Library
Exception Safety" of The C++ Programming Language.[3] That appendix can
be downloaded from my home pages.[4]

Based on that line of thinking, C with Classes also allowed you to define
a call() function that was called before entry into a member function and
a return() function that was called after exit from a member function.
The call()/return() mechanism was meant to allow a programmer to manage
resources needed for an individual member function invocation. This
allowed me to implement monitors for the first task library. A task's
call() grabbed a lock and its matching return() released the lock. The
idea came partly from Lisp's :before and :after methods. However, the
notion wasn't perfectly general -- for example, you couldn't access
arguments for a member function call from call(). Worse, I completely
failed to convince people of the usefulness of this notion, so I removed
call() and return() when I defined C++.
</quote>

The last sentence is what has me baffled.

why do we need it as a standard mechanism? Cant we have the call to
call() at the begining of every member function and return() before
every return? May be something like
#define RETURN returnf(); return
It may prove significant that call() is invoked _before_ the member
function, and that return() is invoked _after_ the return has completed.
I'm thinking in terms of synchronization points. Another issue would be
what to do about exceptions. I don't claim to be any kind of an expert on
this matter. I've very briefly looked at some discussions of how this is
used in CLOS. In that case there is at lease one other function
called "around" which seems to provide parameter interception. The part of
call/return that appealed to me was that it seems like a good way to
support concurrency.

I will note that there are very few references listed in the Java Language
Specification. Among them is the CLOS Specification. Only one author
appears with more than one title.
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Dec 18 '06 #36
Steven T. Hatton wrote:
>
It may prove significant that call() is invoked _before_ the member
function, and that return() is invoked _after_ the return has completed.
I'm thinking in terms of synchronization points. Another issue would be
what to do about exceptions. I don't claim to be any kind of an expert on
this matter. I've very briefly looked at some discussions of how this is
used in CLOS. In that case there is at lease one other function
called "around" which seems to provide parameter interception. The part of
call/return that appealed to me was that it seems like a good way to
support concurrency.
You should look closely at Java's experience with synchronized methods.
Library designers have moved away from them, because the lock almost
always occurs too soon, killing performance. It's much better to defer
locking until you've finished some preliminaries, and possibly decided
that a lock isn't even needed.

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
Dec 18 '06 #37
Pete Becker wrote:
Steven T. Hatton wrote:
>>
It may prove significant that call() is invoked _before_ the member
function, and that return() is invoked _after_ the return has completed.
I'm thinking in terms of synchronization points. Another issue would be
what to do about exceptions. I don't claim to be any kind of an expert
on
this matter. I've very briefly looked at some discussions of how this is
used in CLOS. In that case there is at lease one other function
called "around" which seems to provide parameter interception. The part
of call/return that appealed to me was that it seems like a good way to
support concurrency.

You should look closely at Java's experience with synchronized methods.
Library designers have moved away from them, because the lock almost
always occurs too soon, killing performance. It's much better to defer
locking until you've finished some preliminaries, and possibly decided
that a lock isn't even needed.
So I've read. So far the only difference between Java's threading and
threading in C++ that I've noticed is that I was able to make use of what
Java provides. Can you provide detailed information describing the adverse
impact of Java's threading model in typical applications? The only
hands-on experience I have with a functioning large-scale concurrent
application is the component that provides AKO (Army Knowledge Online) with
access to the US Army's personnel database. We used BEA WebLogic.

There are a lot of issues I have not been able to explore regarding
threading in C++. I'm suspicious of claims of significant performance
enhancements in the general case that require computing the need for
locking at runtime. You will need to pay for that computation somehow.

It's not clear to me whether a distinction between read locks and write
locks would be useful in concurrent programs. Java has no concept of
constness beyond immutability. That, in itself, suggests C++ could use the
same basic threading model and provide superior performance. There are
probably many cases in which the need for locking could be determined at
design time, or at compile time.

When all is said and done, it seems likely there will be a need to take
action "within" synchronization points.

--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Dec 18 '06 #38

Steven T. Hatton wrote:
wk****@yahoo.co m wrote:
Then I also missed the Socratic double irony, because I've heard
more than once the argument that C++ is a bad language because
it was devolped iteratively based on experience with practical
usage.

I don't believe I've ever made such a claim.
Sorry, I didn't mean to imply that you did. It did seem that you
were (seriously) saying that C++ was negatively impacted
because the designer thought that a strong consensus of expert
users trumphed his own intuition. (Hence the double irony if
you only meant it ironically.)
What is most evident to me
right now regarding the faults of C++ is not really inherent to the
language. When I first started trying to learn C++ I bought a copy of the
Standard. Many people told me that reading the Standard was the wrong way
to go about learning C++. My own experience tells me that it was somewhat
beneficial, but not completely effective.

Some of the observations I made back then were that the Standard lacked
clarity, that terms were not well defined and that some of the wording was
overly cleaver. I was told that the failing was on my part, and that the
Standard was written in highly specialized language only accessible to
experts.

http://groups.google.com/group/comp....836121a85f07b6
Well, mal de muchos, consuelo de tontos, but the C++ Standard is easier
to use than alot of the other technical standards I've had to deal
with. So
the problem is not specific to C++. And anyway, C++ was an important,
usable, and surprisingly portable language for many years before the
1998 Standard was issued.

Dec 18 '06 #39
wk****@yahoo.co m wrote:
>
Steven T. Hatton wrote:
>wk****@yahoo.co m wrote:
Then I also missed the Socratic double irony, because I've heard
more than once the argument that C++ is a bad language because
it was devolped iteratively based on experience with practical
usage.

I don't believe I've ever made such a claim.

Sorry, I didn't mean to imply that you did. It did seem that you
were (seriously) saying that C++ was negatively impacted
because the designer thought that a strong consensus of expert
users trumphed his own intuition. (Hence the double irony if
you only meant it ironically.)
My comment was "Bruno was burned at the stake, wasn't he?" If you find any
angle of irony in the various possible interpretations it was probably
intended.
>What is most evident to me
right now regarding the faults of C++ is not really inherent to the
language. When I first started trying to learn C++ I bought a copy of
the
Standard. Many people told me that reading the Standard was the wrong
way
to go about learning C++. My own experience tells me that it was
somewhat beneficial, but not completely effective.

Some of the observations I made back then were that the Standard lacked
clarity, that terms were not well defined and that some of the wording
was
overly cleaver. I was told that the failing was on my part, and that the
Standard was written in highly specialized language only accessible to
experts.

http://groups.google.com/group/comp....836121a85f07b6
>
Well, mal de muchos, consuelo de tontos, but the C++ Standard is easier
to use than alot of the other technical standards I've had to deal
with. So
the problem is not specific to C++. And anyway, C++ was an important,
usable, and surprisingly portable language for many years before the
1998 Standard was issued.
The wording of the C++ Standard could and should be better. A formal
glossary of terms will help the authors express their exact meanings more
effectively. It will help avoid ambiguities in the specification. It will
help implementers to correctly, consistently and efficiently write
compilers. It will make the language easier to teach and to learn. It will
facilitate adding or modifying features (in the _rare_ cases when that is
needed). It will help identify and eliminate design flaws. And most
importantly, it will make the language easier and more enjoyable to use.

IMO comparing C++ (or the Standard document) to other languages is less
beneficial in most cases than comparing it to its potential.
--
NOUN:1. Money or property bequeathed to another by will. 2. Something handed
down from an ancestor or a predecessor or from the past: a legacy of
religious freedom. ETYMOLOGY: MidE legacie, office of a deputy, from OF,
from ML legatia, from L legare, to depute, bequeath. www.bartleby.com/61/
Dec 18 '06 #40

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

Similar topics

1
1812
by: Stephen Thorne | last post by:
Decorators have been getting lots of air-time at the moment, but only really the syntax. After a short discussion on irc the other night I decided to download python2.4 from experimental and write out some truely worthy decorator hacks. I implemented multimethods as a warm-up, and then implemented tail call elimination. Presented here is a brief synopsis of both, and then the implementations....
5
2692
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
5
2810
by: Seong-Kook Shin | last post by:
Hi, I'm reading Steve's "C Programming FAQs" in book version, and have two question regarding to Q11.16 ... Also, a `return' from `main' cannot be expected to work if data local to main might be needed during cleanup. (Finally the two forms are obviously not equivalent in a recursive call to `main'). My questions are
3
4952
by: Cong Wang | last post by:
Hi,all! I found an interesting problem,it is that how to implement a C function which can be called once and return twice? Just like the POSIX function fork() or the library function longjmp().Only via using asm? It is strange that I have searched the google groups and FAQs of this group and "googled" the internet but find none useful info. Thanks for any reply!
13
4150
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make sense to punch out from managed code to native code (I was using IJW) in order to do some amount of floating point work and, if so, what that certain amount of floating point work was approximately. To attempt to do this I made a program that...
5
2317
by: SStory | last post by:
Hi all, I really needed to get the icons associated with each file that I want to show in a listview. I used the follow modified code sniplets found on the internet. I have left in commented code for anyone else who may be looking to do the same.
11
2741
by: Felix Kater | last post by:
Hi, I can compile and run this code (see below) which twice calls the function f, first with too less, second with too much arguments. But is it legal and free of memory leaks and other problems? Of course, I presume that inside f I don't access i in case it was called via g. int f(int i){ /* ... */ return 0; }
44
2954
by: Steven D'Aprano | last post by:
I have a class which is not intended to be instantiated. Instead of using the class to creating an instance and then operate on it, I use the class directly, with classmethods. Essentially, the class is used as a function that keeps state from one call to the next. The problem is that I don't know what to call such a thing! "Abstract class" isn't right, because that implies that you should subclass the class and then instantiate the...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.