comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: Disallowing Pre-Defined Operations
Date: 2000/03/09
Date: 2000-03-09T00:00:00+00:00	[thread overview]
Message-ID: <yecaek7qri9.fsf@king.cts.com> (raw)
In-Reply-To: 8a9eeg$qtv$1@newpoisson.nosc.mil

claveman@cod.nosc.mil (Charles H. Sampson) writes:
>      During the deliberations that led to Ada 95, was a mechanism for 
> disallowing the pre-defined operations of a type considered?  By "disal-
> lowing" I mean some way of informing the compiler that an attempt to use 
> a certain pre-defined operation is a compile-time error.  Did anyone 
> even ask for it?  (Obviously I didn't, even though I've thought since 
> the mid-eighties that it would be a useful capability to have.)

That seems like a good idea, but it would cause problems for generics.
If you forbid "*" on a floating-point type, you can't use it to
instantiate a generic that takes a floating-point formal type.  This
includes Float_IO (which very likely uses "*" and/or "/" internally).
It also introduces some conceptual problems with the built-in
attributes like 'Image and 'Value, though I suppose the language
definition could just ignore these problems.

It's too bad you can't define literals for a private type, but you can
come close by overload the unary "+" operator.  For example:

    type Time_Type is private;
    type Delta_Time_Type is private;
    function "-"(Left: Time_Type; Right: Time_Type) return Delta_Time_Type;
    function "-"(Left: Time_Type; Right: Delta_Time_Type) return Time_Type;
    -- other appropriate operations
    
    function "+"(Right: Float) return Time_Type;
    function "+"(Right: Float) return Delta_Time_Type;

You can then use:

    T : Time_Type := +123.45; -- or whatever
    T_Minus_1 : Time_Type := T - (+1.0);
    
I haven't tried compiling this, so I'm not certain it will actually
work, and I may be missing some obvious flaw.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center           <*>  <http://www.sdsc.edu/~kst>
Welcome to the last year of the 20th century.




  reply	other threads:[~2000-03-09  0:00 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-03-10  0:00 Disallowing Pre-Defined Operations Charles H. Sampson
2000-03-09  0:00 ` Keith Thompson [this message]
2000-03-09  0:00 ` Samuel T. Harris
2000-03-12  0:00   ` Steven Hovater
2000-03-10  0:00 ` mark_biggar
2000-03-10  0:00 ` Jean-Pierre Rosen
2000-03-11  0:00   ` Tarjei Tj�stheim Jensen
2000-03-11  0:00     ` James S. Rogers
2000-03-13  0:00       ` Tarjei T. Jensen
2000-03-13  0:00     ` Robert Dewar
2000-03-13  0:00       ` Keith Thompson
2000-03-15  0:00         ` Robert Dewar
2000-03-13  0:00     ` dmitry6243
2000-03-15  0:00     ` Charles H. Sampson
2000-03-15  0:00       ` Robert Dewar
2000-03-21  0:00         ` Charles H. Sampson
2000-03-21  0:00           ` Robert Dewar
2000-03-21  0:00           ` Robert A Duff
2000-03-12  0:00   ` claveman
2000-03-12  0:00     ` Robert A Duff
2000-03-13  0:00       ` Tarjei T. Jensen
2000-03-13  0:00         ` Robert A Duff
2000-03-13  0:00         ` Robert Dewar
2000-03-15  0:00       ` Charles H. Sampson
2000-03-15  0:00         ` Tucker Taft
2000-03-15  0:00           ` Paul Graham
2000-03-16  0:00             ` Charles Hixson
2000-03-17  0:00               ` Paul Graham
2000-03-17  0:00                 ` Charles Hixson
2000-03-18  0:00                   ` Robert Dewar
2000-03-20  0:00                     ` Charles Hixson
2000-03-20  0:00                       ` Robert Dewar
2000-03-16  0:00             ` Robert Dewar
2000-03-16  0:00           ` Bryce Bardin
2000-03-16  0:00           ` Tarjei T. Jensen
2000-03-16  0:00             ` Dale Stanbrough
2000-03-16  0:00             ` mark_biggar
2000-03-17  0:00         ` Robert A Duff
2000-03-13  0:00     ` Ted Dennison
2000-03-14  0:00 ` Nick Roberts
2000-03-15  0:00   ` Robert Dewar
2000-03-17  0:00 ` William A Whitaker
2000-03-18  0:00   ` Robert Dewar
2000-03-22  0:00     ` William A Whitaker
2000-03-23  0:00       ` Robert Dewar
2000-04-06  0:00         ` Robert I. Eachus
2000-04-05  0:00           ` Marin D. Condic
2000-04-06  0:00             ` Robert Dewar
2000-04-06  0:00               ` Marin D. Condic
2000-04-07  0:00                 ` Robert Dewar
2000-04-07  0:00                   ` Marin D. Condic
2000-04-07  0:00                 ` dale
2000-04-07  0:00                   ` Marin D. Condic
2000-04-07  0:00                     ` Tarjei T. Jensen
2000-04-07  0:00                       ` Marin D. Condic
2000-04-07  0:00                         ` tmoran
2000-04-07  0:00                           ` Marin D. Condic
2000-04-08  0:00                             ` Vladimir Olensky
2000-04-08  0:00                             ` Vladimir Olensky
2000-04-08  0:00                         ` Dale Stanbrough
2000-04-10  0:00                         ` Tarjei T. Jensen
2000-04-15  0:00                         ` Niklas Holsti
2000-04-15  0:00                           ` Marin D. Condic
2000-04-09  0:00               ` Robert I. Eachus
2000-03-18  0:00   ` Robert Dewar
2000-03-18  0:00   ` Robert Dewar
replies disabled

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