comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Question about library-level functions
Date: Sun, 16 Dec 2012 18:31:08 +0000
Date: 2012-12-16T18:31:08+00:00	[thread overview]
Message-ID: <ly38z5zw5v.fsf@pushface.org> (raw)
In-Reply-To: a7a82a85-48e4-4ded-b090-06f62bd3b0b6@googlegroups.com

AdaMagica <christ-usch.grein@t-online.de> writes:

> On Sunday, December 16, 2012 10:43:41 AM UTC+1, Simon Wright wrote:
>> ytomino writes:
>>
>> > function alloc return access lifetime.T is
>> > begin
>> >    return new lifetime.T'(lifetime.Create);
>> >    -- lifetime.Finalize may be called here
>> > end alloc;
>>
>> I think that what's happening is that a (limited) temporary lifetime.T
>> object is created (on the heap, or perhaps the secondary stack). Its
>> access is taken for the return value, and then (because we're leaving
>> the scope) it gets finalized.
>
> Looks like so, but IMHO this is illegal. A limited object must be
> created in-place. (Of course an implementation can do as it likes and
> create first a temporary object, then copy it to the final one and
> finalize the temporary *if* the result is as though it was created
> in-place. But here, it seems like the same object is finalized twice.)
>
> What may be temporary and copied it the access value and not the
> accessed object. It's standard to create an object via an access and
> return the latter - the object must not be finalized, of course.
>
> Creating via anonymous access is evil - how can ou ever deallocate it?
> This should be verboten by the language.

OP is quite right that the code behaves properly if alloc() is declared
in a package, and misbehaves when alloc() is declared at library
level. I think this has to be a bug.

Who's going to report it?



  parent reply	other threads:[~2012-12-16 18:31 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-15  3:38 Question about library-level functions ytomino
2012-12-15  9:47 ` AdaMagica
2012-12-15 10:50   ` ytomino
2012-12-15 11:38     ` AdaMagica
2012-12-17 19:49       ` Adam Beneschan
2012-12-18  2:26         ` ytomino
2012-12-15 15:23 ` sbelmont700
2012-12-16  6:09   ` ytomino
2012-12-16  9:43 ` Simon Wright
2012-12-16 10:21   ` AdaMagica
2012-12-16 13:07     ` ytomino
2012-12-16 18:31     ` Simon Wright [this message]
2012-12-18  3:18       ` ytomino
2012-12-18  0:07     ` Randy Brukardt
2012-12-16 13:34   ` ytomino
2012-12-16 15:54     ` AdaMagica
2012-12-18  0:09       ` Randy Brukardt
replies disabled

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