comp.lang.ada
 help / color / mirror / Atom feed
From: RTOAL@lmumail.lmu.edu (Ray Toal)
Subject: Re: Constructor in ADA9X
Date: Wed, 8 Feb 1995 16:55:11
Date: 1995-02-08T16:55:11+00:00	[thread overview]
Message-ID: <RTOAL.13.0010EBFD@lmumail.lmu.edu> (raw)
In-Reply-To: 3h6bno$7q8@toads.pgh.pa.us

In article <3h6bno$7q8@toads.pgh.pa.us> tore@lis.pitt.edu (Tore Joergensen) writes:
>Path: news.lmu.edu!news.mic.ucla.edu!library.ucla.edu!agate!howland.reston.ans.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!godot.cc.duq.edu!toads.pgh.pa.us!tore
>From: tore@lis.pitt.edu (Tore Joergensen)
>Newsgroups: comp.lang.ada
>Subject: Re: Constructor in ADA9X
>Date: 6 Feb 1995 23:35:20 GMT
>Organization: University of Pittsburgh
>Lines: 23
>Message-ID: <3h6bno$7q8@toads.pgh.pa.us>
>References: <3h61fh$92n@rc1.vub.ac.be>
>NNTP-Posting-Host: shrike.lis.pitt.edu
>X-Newsreader: TIN [version 1.2 PL2]


>DELROEUX JEAN-YVES (jydelr@vub.ac.be) wrote:
>:  I would like to know how make a constructor ( like in C++ ) in ADA9X. Is it
>: possible ?? If yes how and if not, why and how can I simulate constructors ?

>:       Thanks for your help.

>:       DELROEUX Jean - Yves

>From the Ada9x-RefManual's index:
>constructor 
>      See initialization 3.3.1(19), 7.6(1) 
>      See initialization expression 3.3.1(4) 
>      See Initialize 7.6(1) 
>      See initialized alligator 4.8(4) 
>You can find the ref.manual with a web-browser on
>http://lglwww.epfl.ch/Ada/LRM/9X/rm9x/

One thing about C++ constructors that I haven't really been able to
simulate are the fact that they are NOT inherited in C++ (which is
useful.)  Consider:

package Shapes is

  type Shape is abstract tagged record;
  procedure Display (S; Shape) is abstract;

  type Circle is new Shape with private;
  function Make_Circle (C: in out Circle; Radius: Real) return Circle;
  procedure Display (C: Circle);

  type Rectangle is new Shape with private;
  function Make_Rectangle (R: in out Rectangle; Width, Height: Real)
                                        return Rectangle;
  procedure Display (R: Rectangle);

  type Square is new Rectangle with private;
  function Make_Square (S: in out Square; Side_Length: Real) return Square;
  procedure Display (S: Square);

  type Triangle is ....

private

   ...

end Shapes;

You will get the error message "Make_Rectangle must be redeclared for
type Square..."  Does anyone know a nice, clean workaround?

Ray Toal




  parent reply	other threads:[~1995-02-08 16:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-02-06 20:40 Constructor in ADA9X DELROEUX JEAN-YVES
1995-02-06 23:35 ` Tore Joergensen
1995-02-08  6:09   ` Kenneth Almquist
1995-02-08 16:55   ` Ray Toal [this message]
1995-02-10 13:49     ` Robert A Duff
1995-02-11 11:46       ` Stephane Barbey
1995-02-10 22:38     ` Michael Feldman
1995-02-08 14:42 ` Tucker Taft
1995-02-10  0:22   ` Robert I. Eachus
replies disabled

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