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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f9c7f7f00103ac6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1995-02-08 16:55:11 PST Path: nntp.gmd.de!newsserver.jvnc.net!nntpserver.pppl.gov!princeton!udel!gatech!howland.reston.ans.net!agate!library.ucla.edu!news.mic.ucla.edu!news.lmu.edu!eecs2.LMU.edu!RTOAL From: RTOAL@lmumail.lmu.edu (Ray Toal) Newsgroups: comp.lang.ada Subject: Re: Constructor in ADA9X Date: Wed, 8 Feb 1995 16:55:11 Organization: Loyola Marymount University Message-ID: References: <3h61fh$92n@rc1.vub.ac.be> <3h6bno$7q8@toads.pgh.pa.us> NNTP-Posting-Host: eecs2.lmu.edu X-Newsreader: Trumpet for Windows [Version 1.0 Rev Final Beta #6] Date: 1995-02-08T16:55:11+00:00 List-Id: 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