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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6b6619eb9cada212 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: Help me to chose between ADA 95 and C++ Date: 1999/12/14 Message-ID: <3856c969_3@news1.prserv.net>#1/1 X-Deja-AN: 560728958 Content-transfer-encoding: 7bit References: <01bf37fb$a91afb60$0564a8c0@IS-D2D04C.test> <829rbv$a8m$1@nntp6.atl.mindspring.net> <01bf3e32$0b9dc880$022a6282@dieppe> <385112AE.7E2CFA9@rdel.co.uk> <833d8i$sjf$1@nntp5.atl.mindspring.net> <38566835.B4A2D48@rdel.co.uk> <8363hv$6cu$1@nntp9.atl.mindspring.net> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 14 Dec 1999 22:49:13 GMT, 129.37.62.81 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-14T00:00:00+00:00 List-Id: In article <8363hv$6cu$1@nntp9.atl.mindspring.net> , Richard D Riehle wrote: > package Real_Number is > type Real is private; > function "+" (L, R : Real) return Real; > -- same for all other operators > Divide_By_Zero : exception; > -- more exceptions > private > type Real is digits 9; > end Real_Number; > > The corresponding package body can have additional checks within > each operation to ensure conformity to the application constraints. > It turns out, though, that implementing this, in Ada, is somewhat > tedious because of the need to avoid recursive calls within each > function in the package body. It can be done. Indeed it can. You have a couple of possibilities: 1) Implement the full view of the type as a record containing a single floating point component; or, 2) Implement the full view of the type as a private derivation, and do type conversions in the body to convert between public and private views of the type.