comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Garbage Collection ???
Date: Thu, 19 Apr 2012 15:26:03 -0500
Date: 2012-04-19T15:26:03-05:00	[thread overview]
Message-ID: <jmpscu$ui7$1@munin.nbi.dk> (raw)
In-Reply-To: wcc4nsf4wm4.fsf@shell01.TheWorld.com

"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote in message 
news:wcc4nsf4wm4.fsf@shell01.TheWorld.com...
> Julian Leyh <julian@vgai.de> writes:
>
>> Am Samstag, 14. April 2012 20:21:17 UTC+2 schrieb Robert A Duff:
>>> In Ada 2012, you can say:
>>>
>>>     type T_Ptr_Opt is access all T;
>>>     subtype T_Ptr is T_Ptr_Opt with
>>>         Dynamic_Predicate => T_Ptr /= null;
>>
>> In Ada 2005, you can already say:
>>
>>     type T_Ptr_Opt is access all T;
>>     subtype T_Ptr is not null T_Ptr_Opt;
>
> Right, but that's less useful, because it forces you
> to initialize your variables (e.g. record components)
> before you're ready to.

I don't think that's really true, since the rule that you're referring to 
applies if *any* components are initialized. So while it is true (but a bad 
idea for access types, IMHO) for stand-alone objects, depending on it is 
iffy at best in records.

In all honesty, I think the rule that makes these work different is just a 
bug in Ada 2012. The rule *I* was thinking about only applied to things that 
aren't initialized at all (i.e. scalars), not to things that are initialized 
automatically (access types and Default_Value aspects). In the latter case, 
you can use the object immediately and *never* initialize it -- having the 
predicate not enforced means that it cannot ever be trusted on such objects. 
That seems like a bad way to go (and different from constraints).

Thus, I think the current rule (3.2.4(31/3)) is OK for composite types, but 
it is wrong for elementary types when those are automatically initialized.

(And a null-excluding component - by any means - is almost never a good 
idea. You always need a "nothing/unknown" indicator. Null-exclusions are 
almost exclusively useful for parameters, where you don't need "nothing" 
simply because you don't make the call in that case.)

                                Randy.





  reply	other threads:[~2012-04-19 20:26 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-13 12:14 Garbage Collection ??? ldries46
2012-04-13 13:20 ` Dmitry A. Kazakov
2012-04-13 19:27   ` ldries46
2012-04-13 20:06     ` Dmitry A. Kazakov
2012-04-13 22:49     ` Brian Drummond
2012-04-14  3:21       ` ldries46
2012-04-14 18:21         ` Robert A Duff
2012-04-18  9:07           ` Julian Leyh
2012-04-19 14:36             ` Robert A Duff
2012-04-19 20:26               ` Randy Brukardt [this message]
2012-04-20  7:11                 ` Dmitry A. Kazakov
2012-04-21  0:46                   ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
1992-04-22 18:55 Garbage collection? dog.ee.lbl.gov!overload.lbl.gov!agate!spool.mu.edu!yale.edu!jvnc.net!darw
1992-04-21 23:48 Robert I. Eachus
1992-04-21 23:02 Rick Hudson
1992-04-21 21:09 titan.ksc.nasa.gov!mcroberts
replies disabled

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