comp.lang.ada
 help / color / mirror / Atom feed
From: Mehdi Saada <00120260a@gmail.com>
Subject: Re: On naming space and the good use of qualified expression
Date: Fri, 19 Jan 2018 15:23:21 -0800 (PST)
Date: 2018-01-19T15:23:21-08:00	[thread overview]
Message-ID: <9a061f97-7d4e-4dfc-9581-2fd3768a08ec@googlegroups.com> (raw)
In-Reply-To: <p3tevq$oco$1@dont-email.me>

There's DEFINITELY something fishy here:
Result.Coef(Ind) := P_Rationals."/"((Ind+1),1);

gave the same result:
p_poly_v1_g.adb:82:42: expected private type "T_Rational" defined at p_rationals_g.ads:11, instance at p_poly_v1_g.ads:19
p_poly_v1_g.adb:82:42: found type "Standard.Integer"
gnatmake: "p_poly_v1_g.adb" compilation error


Then, I had the idea of renaming P_Rationals."/", which solves a bit of the ambiguity, pointing at the fact that:

type T_Entier is range <>;
subtype T_Entier_Pos is T_Entier range 1..T_Entier'Last;
subtype T_Degre is Natural range 0..Max;

Ding Dong !! Found it ! Indeed, rational operators are defined for T_Entier, in the P_Rational package. I then merely changed the definitions by:

Max : Positive;
Max_Degre: T_Entier := T_Entier(Max);
subtype T_Degre is T_Entier range 0..Max_Degre;

It works now. Ah, I feel smart now. Every little thing Ada does is magic.. Thanks to the idea of renaming "/", which gave me the supplement of informations I needed to figure things out.
Also, I forgot I had the operator
function "*"(R1 : T_Rationnel; R2 : T_Entier)  return T_Rationnel;
which removes the need of using the construct.
AdaMagica: 1)went on your website, love your humor. I think I'll begin dreaming of Lady Ada, and probably her infamous father too. 2) Specifications are part of the exercice, I can't change it too much or use an already made package, which would, well, negate the entire aim of the exercice :-P


      reply	other threads:[~2018-01-19 23:23 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 17:51 On naming space and the good use of qualified expression Mehdi Saada
2018-01-19 18:37 ` Niklas Holsti
2018-01-19 18:38 ` AdaMagica
2018-01-19 18:55 ` Jeffrey R. Carter
2018-01-19 23:23   ` Mehdi Saada [this message]
replies disabled

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