comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Standard."-" provided to "with function "-" (VAL1 : in VALUE_TYPE) return VALUE_TYPE is <>;" refused:
Date: Fri, 06 Apr 2018 20:43:39 +0100
Date: 2018-04-06T20:43:39+01:00	[thread overview]
Message-ID: <lyvad4m87o.fsf@pushface.org> (raw)
In-Reply-To: 3c392f24-5b12-4290-9ec6-2dc986bb6530@googlegroups.com

Mehdi Saada <00120260a@gmail.com> writes:

> The parameter is
>    with function "-" (VAL1 : in VALUE_TYPE) return VALUE_TYPE is <>;
> from the (simplified) package
> generic
>    type VALUE_TYPE is private;
>    with function "-" (VAL1 : in VALUE_TYPE) return VALUE_TYPE is <>;
> package NUMERIC_SIGNATURE is end Numeric_Signature;
>
> The instantiation is:
> package P_Num is new NUMERIC_SIGNATURE (VALUE_TYPE => Float);
> Package_needing_a_numeric_signature is new SPREADSHEETS.Formula_Cells (P_NUM);
>
> why do I have:
> instantiation error
>  operator "-" not defined for type "VALUE_TYPE" defined at ...

Hard to say without seeing the actual spec of
Spreadsheets.Formula_Cells. But I think you need to 'use' the formal
name of the formal generic signature package.

   generic
      type T is private;
      pragma Warnings (Off, "is not referenced"); -- ~ 15 year old GNAT bug
      with function "*" (L, R : in T) return T is <>;
   package Sig is end Sig;
   
   with Sig;
   generic
      with package Actual is new Sig (<>);
   package Ops is
      function Square (L, R : Actual.T) return Actual.T;
   end Ops;
   
   package body Ops is
      function Square (L, R : Actual.T) return Actual.T is
         use Actual;                                             -- <<<
      begin
         return L * R;
      end Square;
   end Ops;
   
   with Sig;
   with Ops;
   with Ada.Text_IO; use Ada.Text_IO;
   procedure T is
      package Ints is new Sig (Integer);
      package Ops_Int is new Ops (Ints);
      package Floats is new Sig (Float);
      package Ops_Float is new Ops (Floats);
   begin
      Put_Line (Ops_Int.Square (9, 9)'Image);
      Put_Line (Ops_Float.Square (9.0, 9.0)'Image);
   end T;


  reply	other threads:[~2018-04-06 19:43 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 17:20 Standard."-" provided to "with function "-" (VAL1 : in VALUE_TYPE) return VALUE_TYPE is <>;" refused: Mehdi Saada
2018-04-06 19:43 ` Simon Wright [this message]
2018-04-06 20:09 ` Mehdi Saada
2018-04-06 21:35   ` Simon Wright
2018-04-06 20:37 ` AdaMagica
2018-04-06 21:39   ` Simon Wright
2018-04-06 23:08     ` Mehdi Saada
2018-04-07  0:05     ` Mehdi Saada
2018-04-07 10:17       ` Mehdi Saada
2018-04-07 10:43         ` Mehdi Saada
2018-04-07 13:37           ` 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