comp.lang.ada
 help / color / mirror / Atom feed
* Extended Type Statements
@ 2006-01-17 18:04 Jeffrey R. Carter
  2006-01-17 19:57 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey R. Carter @ 2006-01-17 18:04 UTC (permalink / raw)


A type defines a set of values and a set of operations on those values. That's 
the definition I learned, and is similar to the one in ARM 3.2. In Ada, some 
type declaration statements define at type, while others don't. For example

type I is range 1 .. 10;

declares a set of values (1 .. 10) and a set of operations on those values ("+", 
"-", and so on), while

type T is limited private;

declares no values and very few operations. Instead, it's the entire package 
spec that T is in that defines the type:

package P_For_T is
    type T is limited private;

    C : constant T;

    procedure Put (Into : in out T; Value : in Integer);

    function Get (From : T) return Integer;
private -- P_For_T
    ...
end P_For_T;

I was wondering if it might be a good idea for a language (probably not Ada) to 
have an extended type statement that covers both concepts with a single 
statement. So an integer type could be declared as something like

type I is
values =>
    range 1 .. 10;
end I;

and an ADT as

type T is
values =>
    C : constant;
operations =>
    limited => True;

    procedure Put (Into : in out T; Value : in Integer);

    function Get (From : T) return Integer;
implementation =>
    private;
end T;

There could be sections in the statement for representation clauses and the like.

Any comments? Would this sort of thing have any value?

-- 
Jeff Carter
"I'm a kike, a yid, a heebie, a hook nose! I'm Kosher,
Mum! I'm a Red Sea pedestrian, and proud of it!"
Monty Python's Life of Brian
77



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-17 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-17 18:04 Extended Type Statements Jeffrey R. Carter
2006-01-17 19:57 ` Dmitry A. Kazakov

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