comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Generic formal type with 'Image
Date: Wed, 6 Jun 2018 17:34:58 +0200
Date: 2018-06-06T17:34:58+02:00	[thread overview]
Message-ID: <pf8uv3$tr4$1@dont-email.me> (raw)
In-Reply-To: <pf8m2r$vj$1@dont-email.me>

On 06/06/2018 03:03 PM, Alejandro R. Mosteo wrote:
> I'm pretty sure the answer is "no", but just in case:

You're right; as things are now, you can't do it. You have to do

generic -- Name
     type Printable is private;
     with function Image (P : Printable) return String is <>;
package Name is
    procedure Proc (P : in Printable);
    function Func (P : Printable) return Boolean;
end Name;

You can then, if you like, do things like

generic -- Name_Discrete
    type Discrete is (<>);
package Name_Discrete is
    procedure Proc (P : in Discrete);
    function Func (P : Discrete) return Boolean;
end Name_Discrete;

with Name;
package body Name_Discrete is
    package Internal is new Name
       (Printable => Discrete, Image => Discrete'Image);

    procedure Proc (P : in Discrete) renames Internal.Proc;
    function Func (P : Discrete) return Boolean renames Internal.Func;
end Name_Discrete;

-- 
Jeff Carter
"You me on the head hitted."
Never Give a Sucker an Even Break
108


  parent reply	other threads:[~2018-06-06 15:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 13:03 Generic formal type with 'Image Alejandro R. Mosteo
2018-06-06 14:18 ` ytomino
2018-06-06 15:34 ` Jeffrey R. Carter [this message]
2018-06-06 18:35 ` Alejandro R. Mosteo
2018-06-07  8:35   ` Marius Amado-Alves
2018-06-07 21:26     ` Randy Brukardt
2018-06-06 18:56 ` Shark8
2018-06-06 20:34   ` Randy Brukardt
replies disabled

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