comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Help - Constructors - ASAP.
Date: 1998/07/26
Date: 1998-07-26T00:00:00+00:00	[thread overview]
Message-ID: <m3lnpg7j5s.fsf@mheaney.ni.net> (raw)
In-Reply-To: 6p75qi$rcj@news.latnet.lv

"Maxim Senin" <maks.tech.swh.lv> 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.









  reply	other threads:[~1998-07-26  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-23  0:00 Help - Constructors - ASAP Maxim Senin
1998-07-26  0:00 ` Matthew Heaney [this message]
1998-07-27  0:00   ` dennison
1998-07-30  0:00     ` Robert I. Eachus
1998-07-30  0:00       ` tedennison
1998-07-31  0:00         ` Matthew Heaney
1998-07-31  0:00         ` Mats Weber
1998-07-31  0:00           ` dennison
1998-08-01  0:00             ` Robert Dewar
1998-08-01  0:00               ` Matthew Heaney
1998-08-01  0:00             ` Matthew Heaney
1998-08-03  0:00             ` Mats Weber
1998-07-31  0:00           ` Robert I. Eachus
1998-08-01  0:00             ` Matthew Heaney
1998-08-01  0:00       ` Robert Dewar
1998-08-01  0:00         ` Matthew Heaney
1998-08-03  0:00           ` Mats Weber
1998-08-03  0:00             ` Matthew Heaney
1998-08-03  0:00               ` Mats Weber
1998-08-04  0:00                 ` Matthew Heaney
1998-08-04  0:00                   ` Mats Weber
1998-08-05  0:00                     ` Matthew Heaney
1998-08-10  0:00           ` Robert I. Eachus
1998-08-03  0:00         ` tedennison
  -- strict thread matches above, loose matches on Subject: below --
1998-07-15  0:00 Maxim Senin
1998-07-16  0:00 ` Stephen Leake
replies disabled

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