From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada 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 Organization: A noiseless patient Spider Message-ID: References: <3c392f24-5b12-4290-9ec6-2dc986bb6530@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="12cd2f60293592c0a44d00711052c2b2"; logging-data="3787"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eSoQkz72mLjuiQGBumO7mU6DQaOglIA8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (darwin) Cancel-Lock: sha1:UqNm0lRlKMzm8m7VzNnWubLGN+Q= sha1:8DVxXwNc6NUxCPUdK9W80ArO624= Xref: reader02.eternal-september.org comp.lang.ada:51360 Date: 2018-04-06T20:43:39+01:00 List-Id: 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;