Tuple literal syntax

Simen kjaeraas simen.kjaras at gmail.com
Thu Oct 7 10:12:45 PDT 2010


retard <re at tard.com.invalid> wrote:

> If you don't have first class tuple constructors and define them with a
> template, that's unfortunately not structural typing.

Might I inquire as to why?

As far as I can see, one can regard a structural type as a set of types,
fields, if you will. Each element of this set has some properties, which
would have to be equal to those of an element of a similar set in an
equal type. That is, (int, string) may be equal to (string, int) if one
considers index not to be one of those properties.

Some structural type systems will consider names part of those properties,
leading (string a, int b) to be equivalent to (int b, string a), if, as
before, index is not an interesting property.

By choosing opposite in these choices (index is important, name is not),
I cannot see that the premise of a structural type system is broken. In
this system, (int b, string a) != (string a, int b), and
(string a, int b) == (string b, int a).

Either of these choices can be implemented in D (the latter I have
implemented), so I cannot quite see where you are going with this.

> The D's structs
> might use the copying semantics from structural typing, but it's a weird
> hybrid type, actually.

In this I agree. Well, given that in D a struct name in D would be unique
(bar linker fuckups), I would argue it is nominative.


-- 
Simen


More information about the Digitalmars-d mailing list