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,555956c1cdd22308 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Help - Constructors - ASAP. Date: 1998/07/16 Message-ID: #1/1 X-Deja-AN: 372068283 References: <35ACBAD6.CC060CEF@tech.swh.lv> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1998-07-16T00:00:00+00:00 List-Id: Maxim Senin writes: > How to write constructor? > > I thought about defining functions: > > function newEvent (eventSource : Object, eventType : EventTypes, eventData : > EventDataType) return Event is > ret : Event; > begin > ret := new Event; > ret.source := eventSource; > return (eventSource, eventType, eventData); > end; > > Hope to hear from you... Better is: type Event is record ... end record; type Event_Access is access Event; function newEvent (Param1 : Param1_type) return Event_Access is begin return new Event (Param1); end newEvent; or, if Event is limited, or you have some Init procedure: function newEvent (Param1 : Param1_type) return Event_Access is temp : event_Access := new Event; begin Init (temp.all, Param1); return temp; end newEvent; > > Maxim