comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Help - Constructors - ASAP.
Date: 1998/07/16
Date: 1998-07-16T00:00:00+00:00	[thread overview]
Message-ID: <uk95d3ddu.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 35ACBAD6.CC060CEF@tech.swh.lv

Maxim Senin <maks@tech.swh.lv> writes:

> How to write constructor?

> <snip> 

> 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




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

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-15  0:00 Help - Constructors - ASAP Maxim Senin
1998-07-16  0:00 ` Stephen Leake [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-07-23  0:00 Maxim Senin
1998-07-26  0:00 ` Matthew Heaney
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           ` Robert I. Eachus
1998-08-01  0:00             ` Matthew Heaney
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-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
replies disabled

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