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,e19a809544945098 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!w34g2000prm.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: worrying behaviour Date: Fri, 2 May 2008 19:04:10 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2bd12db4-895e-4f01-8579-0568a4153a75@w34g2000prm.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1209780250 29951 127.0.0.1 (3 May 2008 02:04:10 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 3 May 2008 02:04:10 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w34g2000prm.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:21178 Date: 2008-05-02T19:04:10-07:00 List-Id: On May 2, 6:15 pm, "Randy Brukardt" wrote: > "Adam Beneschan" wrote in message > > news:ea92a206-7617-4968-90c2-31fcc30d5e40@r9g2000prd.googlegroups.com... > ... > > > I'm not sure that there's a good solution in Ada. If you really > > wanted to make sure that the only operators available for My_Int are > > the ones that you remembered to override, you could declare My_Int > > private, but then you'd lose the ability to have numeric literals for > > that type (in other packages). I suppose that having some sort of > > language construct that says "kill all predefined operators for a > > type" would be useful in your case. > > That's not available, but you can kill them one-by-one by declaring them > abstract: > > function "-" (R : My_Int) return My_int is abstract; > > makes "-" effectively undefined for type My_Int. (This is new in Ada 2005, > in Ada 95 it is defined and uncallable -- the difference is that it might > conflict with some user-defined routine and cause trouble.) Right. The reason I didn't mention this was because the original problem appeared to be caused (perhaps hypothetically) by someone forgetting to override an operator in the package; and if they forgot to override it they wouldn't remember to override it with an abstract function either. That's why one construct to get rid of all the predefined functions would work better here, although I'm still not convinced that there's a real need for it. -- Adam