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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cd962bca2451dfbc X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: static objects in ADA Date: 1999/04/21 Message-ID: #1/1 X-Deja-AN: 469221486 References: Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1999-04-21T00:00:00+00:00 List-Id: Mark Elson writes: > Hi, > > I'm a C++ programmer who is new to ADA. I've looked briefly in the Ref > Manual and the FAQ but I can't find the answer to the following question > > Is there an equivalent declaration (in ADA 95) to the static used in > C++, i.e. so that objects are created at link time rather than at run > time? There is no keyword in Ada that means something similar to this meaning of 'static' in C++, but you can easily declare objects that are "created at link time rather than at run-time": package body Stuff is State : State_Type; Count : Integer; end Stuff; Assuming State_Type is a plain record type (not derived from Ada.Finalization.Controlled, not a task type, not a protected type), these objects simply occupy data space; they have no run-time creation code. Note that it is possible to do a similar thing in C++; in that case, State_Type must be a plain struct with no constructor. > > I am working on an embedded app which has a very short "boot-up" time > requirement (10 to 20 ms). I am being told that using objects will > greatly increase my app start time because of object creation overhead. > Any comments appreciated. In Ada, you have complete, direct control over all aspects of object creation. The keyword 'new' must be used to dynamically create an object (as it must be in C++). -- Stephe