• Languages with types like Ada

    From Luke A. Guest@21:1/5 to All on Thu Oct 20 10:01:02 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Luke A. Guest on Fri Oct 21 12:30:01 2022
    Luke A. Guest <[email protected]> wrote:
    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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luke A. Guest@21:1/5 to [email protected] on Fri Oct 21 21:00:13 2022
    On 21/10/2022 13:30, [email protected] wrote:
    Luke A. Guest <[email protected]> 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]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From gah4@21:1/5 to Luke A. Guest on Fri Oct 21 17:09:57 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas F. Burdick@21:1/5 to All on Sat Oct 22 14:30:36 2022
    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" <[email protected]> a écrit :
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bo Persson@21:1/5 to Luke A. Guest on Sat Oct 22 18:17:58 2022
    On 2022-10-21 at 22:00, Luke A. Guest wrote:
    On 21/10/2022 13:30, [email protected] wrote:
    Luke A. Guest <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hans-Peter Diettrich@21:1/5 to Luke A. Guest on Sat Oct 22 11:26:24 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luke A. Guest@21:1/5 to Bo Persson on Sat Oct 22 21:22:31 2022
    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]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christopher F Clark@21:1/5 to All on Sun Oct 23 20:02:38 2022
    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: [email protected] Compiler Resources, Inc. Web Site: http://world.std.com/~compres
    23 Bailey Rd voice: (508) 435-5016
    Berlin, MA 01503 USA twitter: @intel_chris ------------------------------------------------------------------------------

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Luke A. Guest@21:1/5 to Christopher F Clark on Sun Oct 23 20:17:11 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Rumpf@21:1/5 to All on Mon Nov 7 09:58:40 2022
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)