who invented deterministic construction+destruction?

K

Keith H Duggar

Did Stroustrup invent the deterministic constructor+destructor
paradigm? Put another way, was C++ the first language in which
automatic deterministic constructor+destructor support emerged?

What other languages (past or present) support this paradigm?
I'm very curious about the history and evolution of this idea
and language support for it. So any inside anecdotes would be
most welcomed ;-)

KHD
 
A

Alf P. Steinbach

* Keith H Duggar, in [comp.lang.c++]:
Did Stroustrup invent the deterministic constructor+destructor
paradigm? Put another way, was C++ the first language in which
automatic deterministic constructor+destructor support emerged?

What other languages (past or present) support this paradigm?
I'm very curious about the history and evolution of this idea
and language support for it. So any inside anecdotes would be
most welcomed ;-)

I guess most of this stems from the Simula language (Norwegian, of course :) ),
but sad to say I'm unfamiliar with Simula.

There may have been some influence from Hoare "module envelopes"; at last I
think it was Hoare who invented them.

But why not ask Bjarne?


Cheers & hth.,

- Alf


CC: Bjarne
 
A

Alf P. Steinbach

* Alf P. Steinbach:
* Keith H Duggar, in [comp.lang.c++]:
Did Stroustrup invent the deterministic constructor+destructor
paradigm? Put another way, was C++ the first language in which
automatic deterministic constructor+destructor support emerged?

What other languages (past or present) support this paradigm?
I'm very curious about the history and evolution of this idea
and language support for it. So any inside anecdotes would be
most welcomed ;-)

I guess most of this stems from the Simula language (Norwegian, of
course :) ), but sad to say I'm unfamiliar with Simula.

There may have been some influence from Hoare "module envelopes"; at
last I think it was Hoare who invented them.

But why not ask Bjarne?

CC: Bjarne

Bjarne Stroustrup replied:

<quote>
Simula had the equivalent of one constructor (not several constructors) for a
class but no destructors. The idea of construction as creation of working
environment for class member functions (incl. resource acquisition) and
destruction as the inverse operation (incl. resource release) was fundamental to
and very early in C++ (1979). I knew Simula very well and was aware of Naur's
work on invariants (from the mid-1970), but I think the C++
constructor/destructor use and language facilities were original at the time.
</quote>


Cheers & hth.,

- Alf
 
K

Keith H Duggar

* Alf P. Steinbach:
* Alf P. Steinbach:
* Keith H Duggar, in [comp.lang.c++]:
Did Stroustrup invent the deterministic constructor+destructor
paradigm? Put another way, was C++ the first language in which
automatic deterministic constructor+destructor support emerged?
What other languages (past or present) support this paradigm?
I'm very curious about the history and evolution of this idea
and language support for it. So any inside anecdotes would be
most welcomed ;-)
I guess most of this stems from the Simula language (Norwegian, of
course :) ), but sad to say I'm unfamiliar with Simula.
There may have been some influence from Hoare "module envelopes"; at
last I think it was Hoare who invented them.
But why not ask Bjarne?

I guess I didn't want to be a bother. Plus, I thought others in
the community might be interested and might have additional input.
But thank you for asking him!
Bjarne Stroustrup replied:

<quote>
Simula had the equivalent of one constructor (not several constructors) for a
class but no destructors. The idea of construction as creation of working
environment for class member functions (incl. resource acquisition) and
destruction as the inverse operation (incl. resource release) was fundamental to
and very early in C++ (1979). I knew Simula very well and was aware of Naur's
work on invariants (from the mid-1970), but I think the C++
constructor/destructor use and language facilities were original at the time.
</quote>

Cheers & hth.

Thanks! Also, it seems Simula was garbage collected? Given that,
even if it had had destructors they would probably not have been
deterministic.

So as far as Stroustrup knows the idea is original to he and C++.
I'm hoping we get more input from others possibly regarding other
languages we have not considered yet. For example, Lisp; I do not
think any Lisp dialect supports deterministic destruction even
today; but, I'm not 100% sure.

KHD
 
N

Nick Keighley

* Alf P. Steinbach:
* Alf P. Steinbach:
* Keith H Duggar, in [comp.lang.c++]:
Did Stroustrup invent the deterministic constructor+destructor
paradigm? Put another way, was C++ the first language in which
automatic deterministic constructor+destructor support emerged?

So as far as Stroustrup knows the idea is original to he and C++.
I'm hoping we get more input from others possibly regarding other
languages we have not considered yet. For example, Lisp; I do not
think any Lisp dialect supports deterministic destruction even
today; but, I'm not 100% sure.

scheme (a lisp dialect) has something called dynamic-wind that
may be what you want.

http://schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_idx_576

(dynamic-wind before thunk after)

"Calls thunk without arguments, returning the result(s) of this call.
Before and after are called, also without arguments, as required by
the following rules (note that in the absence of calls to
continuations
captured using call-with-current-continuation the three arguments are
called once each, in order). Before is called whenever execution
enters
the dynamic extent of the call to thunk and after is called whenever
it
exits that dynamic extent. The dynamic extent of a procedure call is
the
period between when the call is initiated and when it returns. In
Scheme,
because of call-with-current-continuation, the dynamic extent of a
call
may not be a single, connected time period."

call-with-current-continuation can be thought of as a sort of non-
local
jump.

I don't know if this came before or after C++
 
B

Bo Persson

Keith said:
* Alf P. Steinbach:

Thanks! Also, it seems Simula was garbage collected? Given that,
even if it had had destructors they would probably not have been
deterministic.

Simula was (is?) garbage collected in the sense that unreferenced
memory is reused. Class objects were created with 'new' and stayed
alive until the last reference was dropped. Somewhat like Java, I
guess.

A class body was a block, just like a function body. The block could
contain declarations of variables and nested functions (just like a
function body could!), as well a executable code. The code run as each
object was created.
So as far as Stroustrup knows the [constructor+destructor] idea is
original to he and C++.

Probably. Simula did have new, but no delete. To get rid of an object
you just assigned none (null) to the owning pointer (called a
reference).


Bo Persson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top