comp.lang.ada
 help / color / mirror / Atom feed
* Q Controlled Types
@ 1997-06-05  0:00 Guido Schumacher
  1997-06-06  0:00 ` Anonymous
  1997-06-06  0:00 ` Mark A Biggar
  0 siblings, 2 replies; 6+ messages in thread
From: Guido Schumacher @ 1997-06-05  0:00 UTC (permalink / raw)



Is there a possibility to distinguish two different kinds of situations
in which Finalize can be called from within the body of Finalize?
In other words, is it possible to treat the finalization of an object differently,
depending on the context in which it is performed?
1. Calling of Finalize as part of an assignment operation
2. Finalize is called before the object is destroyed (and no copy is performed)

declare
  V: CT; -- type CT is new controlled with ...
begin 
  ...
  V := E;    -- (1)
  ...
end;         -- (2)

I would appreciate any help.

Thank you

Guido
-- 
Guido Schumacher
Carl von Ossietzky Universitaet Oldenburg
Postfach 2503
26111 Oldenburg
Email: Guido.Schumacher@Informatik.Uni-Oldenburg.de
Tel.: +49 441 798 2370
Fax:  +49 441 798 2145





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q Controlled Types
  1997-06-05  0:00 Guido Schumacher
@ 1997-06-06  0:00 ` Anonymous
  1997-06-07  0:00   ` Robert A Duff
  1997-06-06  0:00 ` Mark A Biggar
  1 sibling, 1 reply; 6+ messages in thread
From: Anonymous @ 1997-06-06  0:00 UTC (permalink / raw)



On 5 Jun 1997 19:27:11 GMT, "Guido Schumacher"
<Guido.Schumacher@Informatik.Uni-Oldenburg.DE> wrote:

> Is there a possibility to distinguish two different kinds of situations
> in which Finalize can be called from within the body of Finalize?
> In other words, is it possible to treat the finalization of an object differently,
> depending on the context in which it is performed?

In a word, "No."

> 1. Calling of Finalize as part of an assignment operation
> 2. Finalize is called before the object is destroyed (and no copy is performed)
> 
> declare
>   V: CT; -- type CT is new controlled with ...
> begin 
>   ...
>   V := E;    -- (1)
>   ...
> end;         -- (2)
> 
> I would appreciate any help.

Now, I'm sure someone will post a response about GNAT-specific
information you can use to determine the context with GNAT, but withing
the confines of the language specification there is no way for Finalize
to know why it is being called.

Should someone prove me wrong, I'd be interested to learn how to do
this.

Jeff Carter  PGP:1024/440FBE21
My real e-mail address: ( carter @ innocon . com )
"Now go away, or I shall taunt you a second time."
Monty Python & the Holy Grail

Posted with Spam Hater - see
http://www.compulink.co.uk/~net-services/spam/




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q Controlled Types
  1997-06-05  0:00 Guido Schumacher
  1997-06-06  0:00 ` Anonymous
@ 1997-06-06  0:00 ` Mark A Biggar
  1 sibling, 0 replies; 6+ messages in thread
From: Mark A Biggar @ 1997-06-06  0:00 UTC (permalink / raw)



In article <5n73uf$m1l@news.Informatik.Uni-Oldenburg.DE> "Guido Schumacher" <Guido.Schumacher@Informatik.Uni-Oldenburg.DE> writes:
>Is there a possibility to distinguish two different kinds of situations
>in which Finalize can be called from within the body of Finalize?
>In other words, is it possible to treat the finalization of an object differently,
>depending on the context in which it is performed?
>1. Calling of Finalize as part of an assignment operation
>2. Finalize is called before the object is destroyed (and no copy is performed)
>declare
>  V: CT; -- type CT is new controlled with ...
>begin 
>  ...
>  V := E;    -- (1)
>  ...
>end;         -- (2)

It would help if you told us WHY you need to do this, although 
that may be moot as I don't htink that there is any way to 
distinguish between those cases.

--
Mark Biggar
mab@wdl.lmco.com






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q Controlled Types
  1997-06-06  0:00 ` Anonymous
@ 1997-06-07  0:00   ` Robert A Duff
  0 siblings, 0 replies; 6+ messages in thread
From: Robert A Duff @ 1997-06-07  0:00 UTC (permalink / raw)



In article <199706061252.OAA22753@basement.replay.com>,
Anonymous <nobody@REPLAY.COM> wrote:
>On 5 Jun 1997 19:27:11 GMT, "Guido Schumacher"
><Guido.Schumacher@Informatik.Uni-Oldenburg.DE> wrote:
>
>> Is there a possibility to distinguish two different kinds of situations
>> in which Finalize can be called from within the body of Finalize?
>> In other words, is it possible to treat the finalization of an object differently,
>> depending on the context in which it is performed?

I'm curious.  Why do you want to do this?

>In a word, "No."

Agreed.

>Should someone prove me wrong, I'd be interested to learn how to do
>this.

Not me.  It seems that Finalize doesn't know whether it's called from
assignment vs at end-of-procedure.

- Bob




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q Controlled Types
@ 1997-06-13  0:00 Guido Schumacher
  1997-06-14  0:00 ` Robert A Duff
  0 siblings, 1 reply; 6+ messages in thread
From: Guido Schumacher @ 1997-06-13  0:00 UTC (permalink / raw)




Robert A Duff wrote:
>Anonymous <nobody@REPLAY.COM> wrote:
Mark A Biggar wrote:
>>On 5 Jun 1997 19:27:11 GMT, "Guido Schumacher"
>><Guido.Schumacher@Informatik.Uni-Oldenburg.DE> wrote:
>>
>>> Is there a possibility to distinguish two different kinds of situations
>>> in which Finalize can be called from within the body of Finalize?
>>> In other words, is it possible to treat the finalization of an object differently,
>>> depending on the context in which it is performed?
>
>I'm curious.  Why do you want to do this?
My intention is to preserve information of a target object in an assignment. The
information (containing a protected object) is stored in an object which can be accessed by an access type. 
A pointer of that access type is a record component of the controlled type.
If it were obvious that a call of finalize is not part of an assignment it would be possible to deallocate the object containing the static information.
The controlled object and the static object would both have the same lifetime.

>>In a word, "No."
>
>Agreed.
>
>>Should someone prove me wrong, I'd be interested to learn how to do
>>this.
>
>Not me.  It seems that Finalize doesn't know whether it's called from
>assignment vs at end-of-procedure.

Thank you for the replies.
Guido
-- 
Guido Schumacher
Carl von Ossietzky Universitaet Oldenburg
Postfach 2503
26111 Oldenburg
Email: Guido.Schumacher@Informatik.Uni-Oldenburg.de
Tel.: +49 441 798 2370
Fax:  +49 441 798 2145





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q Controlled Types
  1997-06-13  0:00 Q Controlled Types Guido Schumacher
@ 1997-06-14  0:00 ` Robert A Duff
  0 siblings, 0 replies; 6+ messages in thread
From: Robert A Duff @ 1997-06-14  0:00 UTC (permalink / raw)



In article <5ns30g$9ui@news.Informatik.Uni-Oldenburg.DE>,
Guido Schumacher <Guido.Schumacher@Informatik.Uni-Oldenburg.DE> wrote:
>My intention is to preserve information of a target object in an
>assignment. The information (containing a protected object) is stored
>in an object which can be accessed by an access type.  A pointer of
>that access type is a record component of the controlled type.  If it
>were obvious that a call of finalize is not part of an assignment it
>would be possible to deallocate the object containing the static
>information.  The controlled object and the static object would both
>have the same lifetime.

Ada's controlled types can't do that directly.

Instead, you probably want to declare a limited controlled type with two
components: the pointer you want to preserve, plus a non-limited (maybe
controlled?) component containing all the other stuff.  Do your
assignments on that second component.  Finalize of that (if it's needed
at all) can do whatever you need it to do, and Finalize of the outer
(limited) thing can deallocate the protected object pointed at by the
pointer.

- Bob




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1997-06-14  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-13  0:00 Q Controlled Types Guido Schumacher
1997-06-14  0:00 ` Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1997-06-05  0:00 Guido Schumacher
1997-06-06  0:00 ` Anonymous
1997-06-07  0:00   ` Robert A Duff
1997-06-06  0:00 ` Mark A Biggar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox