Re: Languages with types like Ada

Christopher F Clark <christopher.f.clark@compiler-resources.com>
Sun, 23 Oct 2022 20:02:38 +0300

          From comp.compilers

Related articles
[2 earlier articles]
Re: Languages with types like Ada laguest@archeia.com (Luke A. Guest) (2022-10-21)
Re: Languages with types like Ada gah4@u.washington.edu (gah4) (2022-10-21)
Re: Languages with types like Ada DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2022-10-22)
Re: Languages with types like Ada thomas@burdick.fr (Thomas F. Burdick) (2022-10-22)
Re: Languages with types like Ada bo@bo-persson.se (Bo Persson) (2022-10-22)
Re: Languages with types like Ada laguest@archeia.com (Luke A. Guest) (2022-10-22)
Re: Languages with types like Ada christopher.f.clark@compiler-resources.com (Christopher F Clark) (2022-10-23)
Re: Languages with types like Ada laguest@archeia.com (Luke A. Guest) (2022-10-23)
Re: Languages with types like Ada a.rumpf@crosssoft.de (Andreas Rumpf) (2022-11-07)
| List of all articles for this month |

From: Christopher F Clark <christopher.f.clark@compiler-resources.com>
Newsgroups: comp.compilers
Date: Sun, 23 Oct 2022 20:02:38 +0300
Organization: Compilers Central
References: 22-10-034 22-10-044
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="15195"; mail-complaints-to="abuse@iecc.com"
Keywords: types
Posted-Date: 23 Oct 2022 14:24:30 EDT

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


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.