comp.lang.ada
 help / color / mirror / Atom feed
* Question: constuctors
@ 1998-08-10  0:00 Maxim Senin
  1998-08-10  0:00 ` Robert Dewar
  1998-08-10  0:00 ` Robert Dewar
  0 siblings, 2 replies; 3+ messages in thread
From: Maxim Senin @ 1998-08-10  0:00 UTC (permalink / raw)


I'm thinking about writing constuctors for my ADA 95 program. Do you know
any tips/tricks/hints how to write constuctors in ADA?

What is extension agregate? Samples?

I've tried following code, but it doesn't compile with my GNAT 3.07 for DOS.

-- package spec --
...
    type    Object is tagged private;
    type    PObject is access all
    type    Event is new Object with private;
    type    FocusEvent is new Event with private;
    type    KeyEvent is new Event with private;
private
    type    Object is new ADA.Finalization.Controlled with null record;
    type    Event (src : PObject) is new Object with record
        source    : PObject := src;
        consumed : Boolean := false;
    end record;
    type    FocusEvent is new Event with null record;
    type    KeyEvent (code : Integer; mask : Integer; typeOfEvent : Integer)
is new Event with record
        keyCode   : Integer := code;
        altMask    : Integer := mask;
        eventType : Integer := typeOfEvent;
    end record;

-- package body --

function    newKeyCode (aSource : PObject; aKeyCode : Integer; aMask :
Integer; anEventType : Integer) is
    return    new KeyCode' (src => aSource, keyCode => aKeyCode, altMask =>
aMask, eventType => anEventType);
end newKeyCode;

<<<<<<<<
This doesn't work. Compiler crashes: it requires extension agregate becouse
KeyCode has private ancestor Event, and Event has private ancestor Object
and so on.
How newly created objects should be initialized????? What is extension
agregate?

In addition, I don't like this way of providing constuctors. If I will have
class derived from KeyEvent, I will have to rewrite such constructor
complettly. Any suggestions?

Thanks you very much.
Maxim






^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question: constuctors
  1998-08-10  0:00 Question: constuctors Maxim Senin
  1998-08-10  0:00 ` Robert Dewar
@ 1998-08-10  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1998-08-10  0:00 UTC (permalink / raw)


<<I've tried following code, but it doesn't compile with my GNAT 3.07 for DOS.
>>

3.07 is really very ancient. At least switch to 3.10p. If necessary switch
to using Win95 to use this version. 





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question: constuctors
  1998-08-10  0:00 Question: constuctors Maxim Senin
@ 1998-08-10  0:00 ` Robert Dewar
  1998-08-10  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1998-08-10  0:00 UTC (permalink / raw)


Maxim said

<<In addition, I don't like this way of providing constuctors. If I will have
class derived from KeyEvent, I will have to rewrite such constructor
complettly. Any suggestions?
>>

No, you wlil not have to rewrite it completely. This is a VFAQ! Check the
archives for many discussions of this point.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-08-10  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-08-10  0:00 Question: constuctors Maxim Senin
1998-08-10  0:00 ` Robert Dewar
1998-08-10  0:00 ` Robert Dewar

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