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