comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam@spam.com>
Subject: Extended Type Statements
Date: Tue, 17 Jan 2006 18:04:03 GMT
Date: 2006-01-17T18:04:03+00:00	[thread overview]
Message-ID: <nkazf.13$Dk.10@newsread3.news.pas.earthlink.net> (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



             reply	other threads:[~2006-01-17 18:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-17 18:04 Jeffrey R. Carter [this message]
2006-01-17 19:57 ` Extended Type Statements Dmitry A. Kazakov
replies disabled

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