comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: "end of declaration"
Date: Wed, 10 Feb 2021 12:59:55 -0800 (PST)	[thread overview]
Message-ID: <a3af674f-c6e8-43b2-89d5-473a98b5d1ben@googlegroups.com> (raw)
In-Reply-To: <82631dc2-2903-4848-b662-eb149331623cn@googlegroups.com>

On Wednesday, February 10, 2021 at 11:40:00 AM UTC-7, 0012... wrote:
> can someone explain in simple terms what are the rules for types' "end of declaration" ? 
> 
> I define a type in the private part of the package, and in the body I clone it (type t_proba2 is new t_proba) to benefit from its predefined operations... since it's a fixed point type I need to, or bam ! recursion... also I want the accuracy etc to stay the same so I would do the same for floating point types too. 
> 
> type T_Proba is delta 0.00001 range 0.0 .. 1.0; 
> for T_Proba'Small use 0.00001; 
> 
> package body P_Proba2 is 
> type t_proba2 is new T_Proba; 
> -- type t_proba2 can't be use before the end of its declaration 
> package Point_Fixe_io is new Ada.Text_Io.Fixed_IO(T_Proba); 
> 
> so I rather defined a different type with the same specifications. ugly. 
> no nicer way to access predefined operations for these cases ?
Use more meaningful names if you can.
You had "Type K is new K", which is obvious nonsense.
Considering the context, I think something like
> type Probability is delta 0.00001 range 0.0 .. 1.0; 
> for Probability'Small use 0.00001;
and
> type Internal_Probability is new Probability;
would be much better readability-/maintainability-wise

      parent reply	other threads:[~2021-02-10 20:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 18:39 "end of declaration" Mehdi Saada
2021-02-10 19:06 ` AdaMagica
2021-02-10 19:21 ` Egil H H
2021-02-10 19:31   ` Mehdi Saada
2021-02-10 21:08     ` Shark8
2021-02-10 22:43       ` Niklas Holsti
2021-02-10 20:59 ` Shark8 [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