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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: no + or - defined for fixed point types in Standard, why ? Date: Wed, 24 Jan 2018 21:25:52 -0600 Organization: JSA Research & Innovation Message-ID: References: <3d796e5f-015e-469c-bbcb-edc3303793ab@googlegroups.com> Injection-Date: Thu, 25 Jan 2018 03:25:52 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="28779"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50135 Date: 2018-01-24T21:25:52-06:00 List-Id: "+" and "-" (and many other operators, as well, look in Chapter 4 of the Ada Standard) are declared at the point of the type declaration, not in package Standard. So if you need to use direct notation for the ones in this program, you have to prefix by the package name that contains the operators (which you didn't provide because you didn't provide a compilable example yet again), not Standard. Ignore the goofy "*" and "/" for fixed point types in Standard, they have a specialized use. The usual operators are declared with the type, just like with integer and float types. Most of the operators in Standard are for use with the predefined types, which a type with an explicit declaration like Modele is not. Derived types get a copy of the operators of the parent type, also declared at the point of the type. So the same is true for T_Proba. Randy. "Mehdi Saada" <00120260a@gmail.com> wrote in message news:3d796e5f-015e-469c-bbcb-edc3303793ab@googlegroups.com... I have to define the addition, substraction and multiplication operators for a fixed point real type, and (though I KNOW you don't do, that, but pass use a parent type whose primitives have not been overrided) I tried to prefix by "Standard" to see what happens. I thought it would just not work. I got that: p_proba1.adb:11:37: warning: instance does not use primitive operation "+" at p_proba1.ads:8 p_proba1.adb:11:37: warning: instance does not use primitive operation "*" at p_proba1.ads:12 p_proba1.adb:11:37: warning: instance does not use primitive operation "-" at p_proba1.ads:16 p_proba1.adb:43:16: "-" not declared in "Standard" I could see that + and - weren't defined for universal_fixed in Standard, though they are indeed, hum, defined in real life. What does it mean ? Here's my type definitions: type T_proba is private; private type Modele is delta 0.001 range 0.0..1.0 with Small => 0.001; -- to style have at hands primitives for fixed point types. type T_proba is new MODELE; -- what I know I should use (but it still say "instance blablabla" And in the body, to define the operation, I convert to Modele. But I got those warnings: p_proba1.adb:11:37: warning: instance does not use primitive operation "+" at p_proba1.ads:8 p_proba1.adb:11:37: warning: instance does not use primitive operation "*" at p_proba1.ads:12 p_proba1.adb:11:37: warning: instance does not use primitive operation "-" at p_proba1.ads:16 Is there another way to refer to the T_proba's primitive operations ? And why does it upset the compiler ? I try to add "overriding" to these three operations, since I read it was a good practice, and I only got one more error: "subprogram "*" is not overriding"... I just read the course's parts on numerics, and I admit I didn't get most of it, by far. Was much much harder to me, than Ada proper. But I don't remember, and can't find info on any of these points... My operators' definitions: function "*" (Un, Deux : in T_Proba) return T_Proba is (Standard."*"(Un, Deux)); function "+" (Un, Deux : in T_Proba) return T_Proba is ((-Un) * (-Deux)); function "-" (Un : in T_Proba) return T_Proba is (Standard."-"(1.0 - UN)); ps: remember, I KNOW it's wrong. but I wonder why exactly.