Jonathan M Davis:

It sounds to me like the reason that structural typing is needed is because Tuple allows you to name its fields, which I've always thought was a bad idea,

I have appreciated named fields of D tuples since the beginning, I have found them quite handy. With them sometimes you don't need to unpack a tuple, you can just access its fields with a nice name, avoiding to move around more than one variable.

In Python there are build-in tuples, and there is a library-defined tuple type that supports names for its fields, it even contains its name, so when you print one of them, it's able to offer a nice textual representation:

from collections import namedtuple
Point = namedtuple('Point', 'x y')
Point(5, 10)
Point(x=5, y=10)

Bye,
bearophile

Reply via email to