comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: worrying behaviour
Date: Fri, 2 May 2008 19:04:10 -0700 (PDT)
Date: 2008-05-02T19:04:10-07:00	[thread overview]
Message-ID: <2bd12db4-895e-4f01-8579-0568a4153a75@w34g2000prm.googlegroups.com> (raw)
In-Reply-To: fvgecn$f55$1@jacob-sparre.dk

On May 2, 6:15 pm, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> "Adam Beneschan" <a...@irvine.com> 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



      reply	other threads:[~2008-05-03  2:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-02 15:26 worrying behaviour echancrure
2008-05-02 15:54 ` Adam Beneschan
2008-05-02 17:41   ` echancrure
2008-05-02 18:31     ` Adam Beneschan
2008-05-03  1:15   ` Randy Brukardt
2008-05-03  2:04     ` Adam Beneschan [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox