473,725 Members | 2,180 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 #1
46 3847
* Steven T. Hatton:
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>
Care to post something that's possible to understand /from the text in
the posting/?

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Dec 15 '06 #2
"Steven T. Hatton" <ch********@ger mania.supwrote in message
news:ZZ******** *************** *******@speakea sy.net...
>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/
The link you gave is talking about some syncronized color class. I don't
see call() and/or return() in it anywhere.

Your post is confused. Wanna try again?
Dec 15 '06 #3
Alf P. Steinbach wrote:
* Steven T. Hatton:
>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>

Care to post something that's possible to understand /from the text in
the posting/?
<quote url="http://www.gotw.ca/publications/c_family_interv iew.htm">
Q: Did you ever add features that your users didn't appreciate as much as
you did, and then have to deprecate or remove them later? What did you
learn from the experience?

Ritchie: I added some things under some pressure from users that I don't
think were done well. Enumeration types are a bit odd, bitfields are odder.
The "static" keyword is very strange, expressing both a storage lifetime
and what the standard calls "linkage" (external visibility). There are many
odd bits here and there.

I can't remember features I added that I had to remove except for some tiny
bits, like the "entry" keyword.

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.
--
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 #4
Steven T. Hatton wrote:
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.
What aspect to you find baffling, the concept or the usefulness? The
concept does appear to be redundant if one uses RAII.

--
Ian Collins.
Dec 15 '06 #5
Ian Collins wrote:
Steven T. Hatton wrote:
>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.

What aspect to you find baffling, the concept or the usefulness? The
concept does appear to be redundant if one uses RAII.
Hu? How are you going to synchronize on a host class using RAII as simply as
using the call() and return() functions which we don't have?

--
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 16 '06 #6
Steven T. Hatton wrote:
Ian Collins wrote:

>>Steven T. Hatton wrote:
>>>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.

What aspect to you find baffling, the concept or the usefulness? The
concept does appear to be redundant if one uses RAII.


Hu? How are you going to synchronize on a host class using RAII as simply as
using the call() and return() functions which we don't have?
"The call()/return() mechanism was meant to allow a programmer to manage
resources needed for an individual member function invocation."

Says nothing about synchronising the host class.

From the example, a lock object constructor could either be passed a
lock, or the object could be a friend of the host class and (by passing
a reference to the host class) use the class's lock that way.

--
Ian Collins.
Dec 16 '06 #7
Ian Collins wrote:
Steven T. Hatton wrote:
>Ian Collins wrote:

>>>Steven T. Hatton wrote:

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
programme r to manage resources needed for an individual member function
invocatio n. 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.

What aspect to you find baffling, the concept or the usefulness? The
concept does appear to be redundant if one uses RAII.


Hu? How are you going to synchronize on a host class using RAII as simply
as using the call() and return() functions which we don't have?
"The call()/return() mechanism was meant to allow a programmer to manage
resources needed for an individual member function invocation."

Says nothing about synchronising the host class.
I didn't even need to get to the sentence explaining what they were used for
when I encountered the discussion. It was obvious.

"Curiously enough, the initial implementation of C with Classes contained a
feature that is not provided by C++, but is often requested. One could
define a function that would implicitly be called before every call of
every member function (except the constructor) and another that would be
called before every return from every member function(except the
destructor). They were called /call/ and /return/ functions. They were
used to provide synchronization for the monitor class in the original task
library[Stroustrup, 1980]"
From the example, a lock object constructor could either be passed a
lock, or the object could be a friend of the host class and (by passing
a reference to the host class) use the class's lock that way.
I have an object of type Lockable. Calling a function on that object
initially acquires a resource called a lock just before control enters the
body of the function. Just before the function returns the lock is
released. That is RAII. All I need to do to create a class with
synchronized member functions is to derive it from Lockable. None of the
member functions need to know a thing about locks.
--
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 16 '06 #8
IR
Steven T. Hatton wrote:
Hu? How are you going to synchronize on a host class using RAII as
simply as using the call() and return() functions which we don't
have?
eg. with Stroustrup's Wrapper templates, which are his answer to the
lack of call() and return() in C++.

To my understanding, they have the same kind of limitations than the
original call()/return() but they are way more flexible and, more
importantly IMHO, non-intrusive.

http://www.research.att.com/~bs/wrapper.pdf
Cheers,
--
IR
Dec 16 '06 #9
IR wrote:
Steven T. Hatton wrote:
>Hu? How are you going to synchronize on a host class using RAII as
simply as using the call() and return() functions which we don't
have?

eg. with Stroustrup's Wrapper templates, which are his answer to the
lack of call() and return() in C++.

To my understanding, they have the same kind of limitations than the
original call()/return()
What that nobody understand their usefulness?
but they are way more flexible and, more
importantly IMHO, non-intrusive.
I don't get the obsession with being "non-intrusive" in C++. There are
times when it makes sense, but I've certainly encountered many times when
it is utterly nonsensical to insist that, for example, a reference counted
pointer be non-intrusive.
http://www.research.att.com/~bs/wrapper.pdf
They certainly don't suffer from the fault of elegant simplicity which
plague call() and return().
--
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 16 '06 #10

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

Similar topics

1
1810
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
2691
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
2805
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
4946
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
4148
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
2736
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
2945
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
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
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
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9113
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...
1
6702
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
6011
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
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
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 we have to send another system
2
2635
muto222
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.