Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Limited ini...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 15 Topic 5621 of 5828
Post > Topic >>

Re: Limited initialization for non-limited types

by Robert A Duff <bobduff@[EMAIL PROTECTED] > Mar 26, 2008 at 10:02 AM

Eric Hughes <eric.eh9@[EMAIL PROTECTED]
> writes:

> Is there any way of getting in-place initialization for non-limited
> objects?

No.

We're thinking about doing that in GNAT as an optimization,
but there's no way to force it.  Note that assignment
statements cannot use build-in-place in all cases.

Perhaps you can get what you want by wrapping a nonlimited type in a
limited record?

> So here's the problem.  I can't trace the Initialize call
> "correctly".  Consider the obvious initialization:
>
>     T : Trace ;
>     A : X := Construct_X( T ) ;
>
> Because X is not a limited type, this code translates thus (in one
> ordering):
>
>     T : Trace ;
>     A : X ;
>     Initialize( A ) ;
>     Temp : X := Construct_X( T ) ; -- as if limited, constructed in
> place
>     Initialize( Temp ) ; -- (*)
>     Finalize( A ) ;
>     A := Temp ;
>     Adjust( A ) ;
>     Finalize( Temp ) ;

That's not a correct translation.  For example, the line marked (*) will
overwrite the result of Construct_X.

To see what GNAT actually generates, use the -gnatD or -gnatG switch.
But there's no guarantee it won't change in future versions!

- Bob
 




 15 Posts in Topic:
Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-26 06:26:42 
Re: Limited initialization for non-limited types
Robert A Duff <bobduff  2008-03-26 10:02:46 
Re: Limited initialization for non-limited types
"Dmitry A. Kazakov&q  2008-03-26 16:08:01 
Re: Limited initialization for non-limited types
"Randy Brukardt"  2008-03-26 17:13:14 
Re: Limited initialization for non-limited types
Lucretia <lucretia9@[E  2008-03-26 16:00:15 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-26 17:07:10 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-26 20:25:05 
Re: Limited initialization for non-limited types
"Randy Brukardt"  2008-03-28 01:56:02 
Re: Limited initialization for non-limited types
Martin Krischik <krisc  2008-03-28 12:23:41 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-28 08:25:08 
Re: Limited initialization for non-limited types
"Randy Brukardt"  2008-03-28 16:53:27 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-28 08:47:37 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-03-28 16:37:04 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-04-01 20:00:02 
Re: Limited initialization for non-limited types
Eric Hughes <eric.eh9@  2008-04-01 21:06:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 14:40:20 CDT 2008.