From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: On naming space and the good use of qualified expression
Date: Fri, 19 Jan 2018 20:37:15 +0200
Date: 2018-01-19T20:37:15+02:00 [thread overview]
Message-ID: <fces6pFjcf7U1@mid.individual.net> (raw)
In-Reply-To: <310b1dea-459b-4a8b-b249-5bb63ea43512@googlegroups.com>
On 18-01-19 19:51 , Mehdi Saada wrote:
> At that point of the program, I have three "/" operators visibles:
> function "/" (A: T_Rational, B: T_Rational) return T_Rational;
> function "/" (A: T_Integer, B: T_Integer) return T_Integer;
> function "/" (A: T_Integer, B: T_Integer) return T_Rational; -- my constructor method
> which makes this expression ambiguous:
> Result.Coef(Ind) := Poly_A.Coef(Ind+1) * (Ind+1)/1;
> (Coef is an array of T_Rational, Ind is of the same type as the index)
>
> For the first time, I grasp what "namespace polution" means.
> I overestimated the compiler's smartness. I tried then:
> Result.Coef(Ind) := Poly_A.Coef(Ind+1) * T_Rational'((Ind+1)/1);
> As I thought qualified expression were a means to inform the compiler
> of the intended type of the parenthesed expression, so that it could
> choose based on the litteral inside AND the different visible homonymous
> functions.
Perhaps you also have a set of overloaded "+" operators, and the
confusion is in the expression Ind+1 ?
That is, should the computation be:
Ind + 1, as Integer + Integer -> Rational
followed by
(Ind + 1) / 1, as Rational / Integer -> Rational ?
Or should it be:
Ind + 1, as Integer + Integer -> Integer
followed by
(Ind + 1) / 1, as Integer / Integer -> Rational ?
Just a guess, of course...
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2018-01-19 18:37 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 [this message]
2018-01-19 18:38 ` AdaMagica
2018-01-19 18:55 ` Jeffrey R. Carter
2018-01-19 23:23 ` Mehdi Saada
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox