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,a883dc07df0d6bb1 X-Google-Attributes: gid103376,public From: Mario Amado Alves Subject: Numeric types Date: 1999/12/08 Message-ID: #1/1 X-Deja-AN: 558265467 Content-Transfer-Encoding: 7bit References: <8233fm$ngf$1@nntp3.atl.mindspring.net> To: "comp.lang.ada@list.deja.com" X-DejaID: _xiz/AIPid6x1lRdaAH9dVBpKfMDee/7i?= X-Authentication-Warning: lexis.di.fct.unl.pt: maa owned process doing -bs Content-Type: text/plain Organization: Deja.com - Before you buy Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-08T00:00:00+00:00 List-Id: The manual defines "numeric types" as the set of integer and real types (cf. e.g. 3.5). Now, is it a codeable type, viz. is it possible to have a generic formal parameter of numeric type, meaning inheriting all numeric operations ("+", "*", ...)? E.g.: generic type Numeric_Type is ...; -- what here? package Blob is -- ... end Blob; package body Blob is -- code using numeric operations ("+", "*", etc.), e.g.: function Blib(A, B, C: Numeric_Type) return Numeric_Type is begin return(A + B * C); end Blib; end Blob; Is this possible to code properly? And how would we write "zero" in this idiom (or any other literal for that matter)? It must be a commonality of "0" and "0.0". This would perhaps work: function Zero return Numeric_Type is begin return(Numeric_Type'Value("0")); exception when others => return(Numeric_Type'Value("0.0")); end Zero; but it sounds like a dirty trick. An attribute 'Zero would be nice... But I am afraid the idiom is just not possible. Please confirm. Perhaps with class wide programming... I will have to go through Chapter 12 of Cohen's bookin once more; perhaps I will be able to answer my onw questions before the end of the year. But from the class hierachy of the types involved, viz: scalar discrete integer ... real ... I think it cannot be done. A numeric class should have the interset fo integer and real operations but leaving out some discrete operations like 'Pos and 'Val. The manual itself warns: "The classes ``numeric'' and ``nonlimited'' represent other classification dimensions and do not fit into the above strictly hierarchical picture. " (3.2) But what "classes" are exactly refered to here? Numeric_IO? Thanks in advance for any suggestions. | |,| | | |RuaFranciscoTaborda24RcD 2815-249CharnecaCaparica 351+212976751 |M|A|R|I|O| mob 939354005 |A|M|A|D|O|DepartmentoDeInformaticaFCT/UNL 2825-114 Caparica 351+212958536 |A|L|V|E|S| fax 212948541 | | | | | | maa@di.fct.unl.pt FCT 212948300 Sent via Deja.com http://www.deja.com/ Before you buy.