• Re: Languages with types like Ada

    From Christopher F Clark@christopher.f.clark@compiler-resources.com to comp.compilers on Sun Oct 23 20:02:38 2022
    From Newsgroup: comp.compilers

    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: christopher.f.clark@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 ------------------------------------------------------------------------------ --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Luke A. Guest@laguest@archeia.com to comp.compilers on Sun Oct 23 20:17:11 2022
    From Newsgroup: comp.compilers

    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.
    --- Synchronet 3.21b-Linux NewsLink 1.2
  • From Andreas Rumpf@a.rumpf@crosssoft.de to comp.compilers on Mon Nov 7 09:58:40 2022
    From Newsgroup: comp.compilers

    Nim supports some of AdarCOs features in this regard. You can specify
    subranges of integers and floats, there is a `distinct` type mechanism etc.

    --- Synchronet 3.21b-Linux NewsLink 1.2