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,dad94612ff745427 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: "Use" and "=" for Tags (was: Re: Instantiating private types with discriminants?) References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1147204659 12.201.97.176 (Tue, 09 May 2006 19:57:39 GMT) NNTP-Posting-Date: Tue, 09 May 2006 19:57:39 GMT Date: Tue, 09 May 2006 19:57:39 GMT Xref: g2news2.google.com comp.lang.ada:4165 Date: 2006-05-09T19:57:39+00:00 List-Id: > > -- problem line: > if Var_A'Tag = Type_A'Tag then > Ada.Integer_Text_IO.Put ( Type_A (Var_A.all).Data); > elsif Var_A'Tag = Type_B'Tag then > Ada.Float_Text_IO.Put ( Type_B (Var_A.all).Data); > end if; You've received some specific solutions, but no general discussion of why this doesn't work. The function "=" you're trying to call is defined in Ada.Tags, and not directly visible here. You can make it directly visible with a "use" clause for Ada.Tags, as you've already discovered, or with a "use type" clause for Ada.Tags.Tag. You can use prefix notation to access it [Ada.Tags."=" (...)]. The subtype membership operation {"in"} is not a subprogram and is always visible, like assignment (":="). Finally, you have the Ada-83 solution to avoiding "use", renaming: function "=" (Left : Ada.Tags.Tag; Right : Ada.Tags.Tag) return Boolean renames Ada.Tags."="; ... if This_Tag = That_Tag then The operators for the predefined types, being in Standard, are always directly visible, so you don't encounter this problem with them. For the most part, though, well designed Ada deals with user-defined types, so understanding this concept is useful. -- Jeff Carter "Apart from the sanitation, the medicine, education, wine, public order, irrigation, roads, the fresh water system, and public health, what have the Romans ever done for us?" Monty Python's Life of Brian 80