Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Languages with types like Ada

48 views
Skip to first unread message

Luke A. Guest

unread,
Oct 20, 2022, 5:08:50 PM10/20/22
to
Hi,

I've been using Ada for a while and I cannot seem to find any other
languages which were developed which had a similar/same way of embedding
information into types (including basic discrete types). Are there any?

And no, i don't mean Pascal. I mean a fully fledged type system like Ada's.

Thanks,
Luke.

anti...@math.uni.wroc.pl

unread,
Oct 21, 2022, 1:45:00 PM10/21/22
to
You probably should be clearer here. IMO distinctive feature of
Ada types is having parametrized types. IIUC Ada essentially the same
mechanism is available in (Extended) Pascal. More general version of
parameterised types was in CLU. FriCAS computer algebra system has its
own language called Spad, having very general parameterised types. If
you like Ada you probably will reject Spad generality, but all above came
from similar design considerations.

Concerning "fully fledged type system", this is really an invitation
to a flame war. You should say which features of Ada type system
you want. And if you want enough features to be exactly the
same as in Ada, then Ada is likely the only language with this
features. After all, what is purpose of developing a "new"
language when it is exactly the same as an existing language
(OK, you may do this due to copyright/trademarks).

--
Waldek Hebisch

Luke A. Guest

unread,
Oct 21, 2022, 7:45:48 PM10/21/22
to
On 21/10/2022 13:30, anti...@math.uni.wroc.pl wrote:
> Luke A. Guest <lag...@archeia.com> wrote:
>> I've been using Ada for a while and I cannot seem to find any other
>> languages which were developed which had a similar/same way of embedding
>> information into types (including basic discrete types). Are there any?
>>
>> And no, i don't mean Pascal. I mean a fully fledged type system like Ada's.
>
> You probably should be clearer here. IMO distinctive feature of
> Ada types is having parametrized types. IIUC Ada essentially the same
> mechanism is available in (Extended) Pascal. More general version of

No, it's not. Pascal cannot define fixed or float types. I'm wondering
what other languages have a type system that can embed information into
the type like Ada does.

> parameterised types was in CLU. FriCAS computer algebra system has its

I'll look into CLU and friCAS thanks.

> own language called Spad, having very general parameterised types. If
> you like Ada you probably will reject Spad generality, but all above came
> from similar design considerations.
>
> Concerning "fully fledged type system", this is really an invitation
> to a flame war. You should say which features of Ada type system
> you want. And if you want enough features to be exactly the
> same as in Ada, then Ada is likely the only language with this

No, I want to know if there are other languages that did anything similar.

> features. After all, what is purpose of developing a "new"
> language when it is exactly the same as an existing language

No, I could write an Ada compiler, but the language is massive and needs
cutting down, the ARG won't do that, so a smaller language with the bits
I want and bits I don't removed is a better way forward.
[In C you can say "typedef short int foo" and now foo is a type.
Like that? -John]

gah4

unread,
Oct 21, 2022, 8:21:12 PM10/21/22
to
On Thursday, October 20, 2022 at 2:08:50 PM UTC-7, Luke A. Guest wrote:

> I've been using Ada for a while and I cannot seem to find any other
> languages which were developed which had a similar/same way of embedding
> information into types (including basic discrete types). Are there any?

It seems that Ada has range types, like Pascal.

It also has something similar to enumeration types that some other languages
now have, at least back to C.

There is a more general question about how to generalize types in a language.

Fortran I has INTEGER and REAL, which have whatever representation the
underlying hardware has. There is no choice.

PL/I, not so many years later, allowed the generalization that one could
specify the number of bits or decimal digits one wanted.

PL/I has attributes instead of types, where one selects the appropriate ones.

There is FIXED or FLOAT, then BINARY or DECIMAL, and REAL or COMPLEX,
and finally precision, and for FIXED types, scale.

You declare FLOAT DEC(10) if you need at least 10 decimal digits.
(The underlying hardware might be binary, but with the appropriate bits.)

This can be slightly inconvenient, as in a type sense (and I think this is what
you are asking), anything with different attributes is a different type.

You can't call a subroutine with FLOAT DEC(10) if it expects FLOAT DEC(16),
even when you know that the underlying representation is the same.

When Fortran finally got the KIND system years later, it works differently.

You can ask for SELECTED_REAL_KIND(10), which gives you an integer.
You then use that when declaring the variables, as a KIND value.

Two variables with the same KIND are the same, even if you ask for
them with different SELECTED_REAL_KIND() arguments.

There are also functions that let you determine, for example, the
precision or radix or exponent range of a specific KIND.

There is no right answer to variable types. All choices make some
things easier, and other things harder.

Hans-Peter Diettrich

unread,
Oct 22, 2022, 2:44:59 PM10/22/22
to
On 10/21/22 10:00 PM, Luke A. Guest wrote:

> No, I want to know if there are other languages that did anything similar.

Object Pascal Language (OPL) AKA Delphi?

DoDi

Thomas F. Burdick

unread,
Oct 22, 2022, 2:47:50 PM10/22/22
to
From the thread so far, I'm also not entirely sure what features of Ada you're
referring to -- perhaps an example of what you mean would help.

Have you looked at the typed functional languages (SML/OCaml, Haskell)? If
you're looking for a maximum amount of information expressed via types,
dependent types do that: Idris and Agda would be the languages to check out
there.


Le 20 octobre 2022 11:01:02 GMT+02:00, "Luke A. Guest" <lag...@archeia.com> a
écrit :

Bo Persson

unread,
Oct 22, 2022, 2:49:58 PM10/22/22
to
On 2022-10-21 at 22:00, Luke A. Guest wrote:
> On 21/10/2022 13:30, anti...@math.uni.wroc.pl wrote:
>> Luke A. Guest <lag...@archeia.com> wrote:
>>> I've been using Ada for a while and I cannot seem to find any other
>>> languages which were developed which had a similar/same way of embedding
>>> information into types (including basic discrete types). Are there any? ...
> No, I could write an Ada compiler, but the language is massive and needs
> cutting down, the ARG won't do that, so a smaller language with the bits
> I want and bits I don't removed is a better way forward.
> [In C you can say "typedef short int foo" and now foo is a type.
> Like that? -John]

But in C foo is still the same type as short, just with a new name.

In Ada you can say 'type foo is new integer' and foo is now just *like*
an integer, but a distinct type with no auto conversions.

Luke A. Guest

unread,
Oct 22, 2022, 10:46:12 PM10/22/22
to
On 22/10/2022 17:17, Bo Persson wrote:
> In Ada you can say 'type foo is new integer' and foo is now just *like*
> an integer, but a distinct type with no auto conversions.

But in Ada, you're supposed to model your types to the domain, unlike
all the other languages which use machine types, int, i32, etc.

On 22/10/2022 13:30, Thomas F. Burdick wrote:
> Have you looked at the typed functional languages (SML/OCaml, Haskell)? If
> you're looking for a maximum amount of information expressed via types,
> dependent types do that: Idris and Agda would be the languages to check out
> there. ...

I'm wanting to know if there are any other languages which move away
from the machine types, int, short, long, i32, i64, etc. and implement
these types like in Ada, where you model the data, range, size, bit
order, etc.

[PL/I does that attribute stuff but two types with the same attributes
are the same. -John]

Christopher F Clark

unread,
Oct 23, 2022, 2:24:34 PM10/23/22
to
I have avoided chiming in on this topic, because I did not understand
what the original author meant by parameterized types and a "real"
type system.

However, some of the discussion has shifted to a topic I do know
something about, type compatibility.

In addition to the myriad other distinctions in type systems such as:
- whether variables carry types or values do
- dynamic types versus static
- strong versus weak types

There seems to be a distinction relevant to this question:
- structural types versus nominal types

In a system with structural types, if two types have the same "layout",
that is are composed of the same units in the same order, they are
considered the same. Python's "duck typing" system is an example
of this form of typing.

In a system with nominal types, if you declare a new type name, it
is distinct from other named types (except for specific exceptions
like inheritance). C++ classes are nominal types.

Each system has its advantages.

Since I have been recently working with Rust, I would say its trait
system is an attempt to cross the boundary. I believe named types
are nominal in rust (I believe unnamed types are structural). However,
you can do structural things with named types by declaring traits
and implementing them on your named types. You still have to
explicitly declare the associations, but you can do it post facto.

--
******************************************************************************
Chris Clark email: christoph...@compiler-resources.com
Compiler Resources, Inc. Web Site: http://world.std.com/~compres
23 Bailey Rd voice: (508) 435-5016
Berlin, MA 01503 USA twitter: @intel_chris
------------------------------------------------------------------------------

Luke A. Guest

unread,
Oct 23, 2022, 9:52:52 PM10/23/22
to
On 23/10/2022 18:02, Christopher F Clark wrote:
> Each system has its advantages.
>
> Since I have been recently working with Rust, I would say its trait
> system is an attempt to cross the boundary. I believe named types
> are nominal in rust (I believe unnamed types are structural). However,
> you can do structural things with named types by declaring traits
> and implementing them on your named types. You still have to
> explicitly declare the associations, but you can do it post facto.

I've still not got around to looking at rust properly bar seeing it and
not liking it much.

One of the things I want to play with are traits as I do think they
worth having and was one of my original goals.

Andreas Rumpf

unread,
Nov 7, 2022, 5:10:50 AM11/7/22
to
Nim supports some of Ada’s features in this regard. You can specify
subranges of integers and floats, there is a `distinct` type mechanism etc.

0 new messages