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: Matthew Heaney Subject: Re: Help - Constructors - ASAP. Date: 1998/07/26 Message-ID: #1/1 X-Deja-AN: 375124863 Sender: matt@mheaney.ni.net References: <6p75qi$rcj@news.latnet.lv> NNTP-Posting-Date: Sun, 26 Jul 1998 14:54:34 PDT Newsgroups: comp.lang.ada Date: 1998-07-26T00:00:00+00:00 List-Id: "Maxim Senin" writes: > 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; In general, functions in Ada serve the role that constructors play in other languages. Your New_Event function is one example of a constructor. If the return type is tagged, then do NOT return the specific type as the return type of the function. Either return the classwide type, or declare the constructors in a nested package called Constructors. This way, the functions won't be primitive operations for the type, and therefore won't be inherited during derivation.