From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-08 12:55:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn4feed!worldnet.att.net!204.127.198.204!attbi_feed4!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail From: "Mark Lundquist" Newsgroups: comp.lang.ada References: <3C34BF2C.6030500@mail.com> <3C34D252.4070307@mail.com> Subject: Re: A case where Ada defaults to unsafe? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Message-ID: <91J_7.1831$fG.7284@rwcrnsc51.ops.asp.att.net> NNTP-Posting-Host: 12.224.45.159 X-Complaints-To: abuse@attbi.com X-Trace: rwcrnsc51.ops.asp.att.net 1010523333 12.224.45.159 (Tue, 08 Jan 2002 20:55:33 GMT) NNTP-Posting-Date: Tue, 08 Jan 2002 20:55:33 GMT Organization: AT&T Broadband Date: Tue, 08 Jan 2002 20:55:33 GMT Xref: archiver1.google.com comp.lang.ada:18666 Date: 2002-01-08T20:55:33+00:00 List-Id: "Brian Rogoff" wrote in message news:Pine.BSF.4.40.0201041614240.84382-100000@bpr.best.vwh.net... > > I know I'm digressing a bit, but I'd prefer that ":=" not be used for > declaring the value of a constant, since I think of that as being > different from assignment. Yes, and unfortunately it goes deeper than that, because in Ada the binding of a value to a constant really *is* an assignment. The same is true for the other case in which an initial value must be supplied: indefinite types. In both cases there are practical ramifications, so it's more than just an aesthetic point or a preference for some way of thinking. These are the cases where "if you have the object, you have a value" (almost like a dual of limitedness, since limitedness says "if you have a value, you have an object"). Anyway... the practical ramifications are: 1) Can't have a constant of a limited type (constant declared by the user of an abstraction; not talking about deferred constants) 2) To have complete control over instances of an abstraction, we often declare the type to be publicly limited and indefinite. But then if objects of the type are to be created, they must be created on the heap and a pointer returned to the client. In many situations where heap allocation would be necessary in some other languages, the design of Ada (functions returning indefinite types; discriminants) allows it to be avoided. The call stack can be thought of (if we must) as serving as a kind of "scoped heap". Defining the binding of an initial value as "assignment" eliminates this advantage for limited types. 3) Sometimes the type must be publicly indefinite for other reasons, and then we still have the same problem as (2), i.e. we are forced to choose between making the type nonlimited (when we may wish -- or indeed require -- it to be limited) vs. using the heap (if the type must be limited, then we must use the heap). 4) For many types we would like to ensure that objects of the type always ha ve a defined value. In the case of limited types, we might be able to use default initialization for this, but that may or may not be possible and it may or may not be enough or really what we want. So the object of the type can be declared, but until an initialization procedure can be called it may not have a defined value, or not the kind of value we want it to have. (There are workarounds for this, though...) It seems like this might be fixable in Ada0X (although you'll probably be stuck with ":=" for constant initialization :-) -- it just would have to mean something different than assigment there) -- mark