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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,78ec96be17741f16 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Unclear error message - please help Date: 08 Oct 2005 19:58:50 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <432C8690.C37D4AE0@alfred-hilscher.de> <43482077.3434FCF3@alfred-hilscher.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1128815930 30744 192.74.137.71 (8 Oct 2005 23:58:50 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 8 Oct 2005 23:58:50 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5515 Date: 2005-10-08T19:58:50-04:00 List-Id: Alfred Hilscher writes: > Robert A Duff schrieb: > > > > Other ideas: > > > > Don't use Integer all over the place, but instead use > > different types, to avoid confusion. > > Ok, I tried it, but it seems that a "subtype" is also not the solution: When I said "different types" I didn't mean "subtypes". > package spec: > package Pkg is > > subtype > Sixteen_Bits is Integer range 0..65535; This is just a subtype of Integer, not a different type. To declare different _types_, you say something like: type Apple_Count is range 1..100; type Orange_Count is range 1..100; These are two different types, and different from Integer, too. Overloading is based on _types_, not subtypes. It depends on what you're doing, but I suspect Sixteen_Bits is not a good name for a type. Name your types after what you're measuring our counting or indexing or whatever -- not how big they are. > procedure Proc (Host : STRING; RC : out Integer; Identifier : in > Sixteen_Bits := 0); > > procedure Proc (Host : STRING; > Time_Response : out Integer; RC : out Integer; > Time_Wait : Integer := 10; > Identifier : in Sixteen_Bits := 0); Think about this: Why are return codes and amounts of time the "same type"? And "identifiers"? > end Pkg; > > program: > with Text_IO; > with Ada.Command_Line; use Ada.Command_Line; > > with Pkg; use Pkg; > > procedure PkgTest is > RC : Integer; > begin > if Argument_Count /= 1 > then > Text_IO.Put_Line ("call: PkgTest "); > return; > end if; > > Proc (Argument (1), RC, Sixteen_Bits (2507)); ^^^^^^^^^^^^^^^^^^^ I think you meant "Sixteen_Bits'(2507)". That is, a qualified expression, not a type conversion. > Text_IO.Put_Line ("RC=" & Integer'Image (RC)); > end PkgTest; > > > > Or use two different names, instead of calling both "Proc". > > No, that's not what I want. The advantage of Ada against other languages > is the overloading: that same things can have the same name(e.g. Put for > all types, unlike WriteInt, WriteCard ... in Modula). > > > - Bob > > Alfred > > -- > ----------------------------------------------------- > To send me mail, please replace "Spam" by "Jedermann" > -----------------------------------------------------