Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #3227

Re: Languages with types like Ada

From Christopher F Clark <christopher.f.clark@compiler-resources.com>
Newsgroups comp.compilers
Subject Re: Languages with types like Ada
Date 2022-10-23 20:02 +0300
Organization Compilers Central
Message-ID <22-10-057@comp.compilers> (permalink)
References <22-10-034@comp.compilers> <22-10-044@comp.compilers>

Show all headers | View raw


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
------------------------------------------------------------------------------

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Languages with types like Ada "Luke A. Guest" <laguest@archeia.com> - 2022-10-20 10:01 +0100
  Re: Languages with types like Ada antispam@math.uni.wroc.pl - 2022-10-21 12:30 +0000
    Re: Languages with types like Ada "Luke A. Guest" <laguest@archeia.com> - 2022-10-21 21:00 +0100
      Re: Languages with types like Ada Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2022-10-22 11:26 +0200
      Re: Languages with types like Ada Bo Persson <bo@bo-persson.se> - 2022-10-22 18:17 +0200
  Re: Languages with types like Ada gah4 <gah4@u.washington.edu> - 2022-10-21 17:09 -0700
  Re: Languages with types like Ada "Thomas F. Burdick" <thomas@burdick.fr> - 2022-10-22 14:30 +0200
    Re: Languages with types like Ada "Luke A. Guest" <laguest@archeia.com> - 2022-10-22 21:22 +0100
    Re: Languages with types like Ada Christopher F Clark <christopher.f.clark@compiler-resources.com> - 2022-10-23 20:02 +0300
      Re: Languages with types like Ada "Luke A. Guest" <laguest@archeia.com> - 2022-10-23 20:17 +0100
    Re: Languages with types like Ada Andreas Rumpf <a.rumpf@crosssoft.de> - 2022-11-07 09:58 +0100

csiph-web