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,FREEMAIL_FROM, WEIRD_PORT autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,a97feceab5b57877,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!e27g2000yqm.googlegroups.com!not-for-mail From: xorque Newsgroups: comp.lang.ada Subject: Saturation arithmetic woes. Date: Wed, 29 Jul 2009 10:03:45 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1a16b458-0201-4320-9787-2836ed58f991@e27g2000yqm.googlegroups.com> NNTP-Posting-Host: 62.249.247.223 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1248887025 9311 127.0.0.1 (29 Jul 2009 17:03:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Jul 2009 17:03:45 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: e27g2000yqm.googlegroups.com; posting-host=62.249.247.223; posting-account=D9GNUgoAAAAmg7CCIh9FhKHNAJmHypsp User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko/2009061212 Iceweasel/3.0.9 (Debian-3.0.9-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:7415 Date: 2009-07-29T10:03:45-07:00 List-Id: generic type Discrete_Type is (<>); package Saturation is type Saturated_Type is new Discrete_Type; function "+" (Left : Saturated_Type; Right : Saturated_Type) return Saturated_Type; end Saturation; package body Saturation is function "+" (Left : Saturated_Type; Right : Saturated_Type) return Saturated_Type is Temp_Left : constant Discrete_Type := Discrete_Type (Left); Temp_Right : constant Discrete_Type := Discrete_Type (Right); begin if Temp_Left + Temp_Right > Discrete_Type'Last then return Saturated_Type (Discrete_Type'Last); end if; if Temp_Left + Temp_Right < Discrete_Type'First then return Saturated_Type (Discrete_Type'First); end if; return Saturated_Type (Temp_Left + Temp_Right); end "+"; end Saturation; with Saturation; with Ada.Text_IO; procedure Main is type T is range 1 .. 10; package T_Saturated is new Saturation (T); package IO renames Ada.Text_IO; package TIO is new Ada.Text_IO.Integer_IO (T_Saturated.Saturated_Type); use type T_Saturated.Saturated_Type; X : constant T_Saturated.Saturated_Type := 5; Y : constant T_Saturated.Saturated_Type := 9; begin TIO.Put (X + Y); -- 10 IO.New_Line; end Main; saturation.adb:10:18: there is no applicable operator "+" for type "Discrete_Type" defined at saturation.ads:2 saturation.adb:13:18: there is no applicable operator "+" for type "Discrete_Type" defined at saturation.ads:2 saturation.adb:17:38: there is no applicable operator "+" for type "Discrete_Type" defined at saturation.ads:2 I'm afraid I'm not well versed in the rules regarding operator name resolution...