tuple field names are ignored
This commit is contained in:
parent
75b7917b3a
commit
c0cc62c6b1
9 changed files with 29 additions and 40 deletions
|
|
@ -31,6 +31,7 @@ algorithm (in pseudo-code) determines type equality:
|
|||
result = typeEqualsAux(a.baseType, b.baseType, s) and
|
||||
typeEqualsAux(a.indexType, b.indexType, s)
|
||||
of tuple:
|
||||
# Note: tuple field names are ignored
|
||||
if a.tupleLen == b.tupleLen:
|
||||
for i in 0..a.tupleLen-1:
|
||||
if not typeEqualsAux(a[i], b[i], s): return false
|
||||
|
|
|
|||
|
|
@ -508,9 +508,8 @@ defines an *order* of the fields. Tuples are meant for heterogeneous storage
|
|||
types with no overhead and few abstraction possibilities. The constructor ``()``
|
||||
can be used to construct tuples. The order of the fields in the constructor
|
||||
must match the order of the tuple's definition. Different tuple-types are
|
||||
*equivalent* if they specify the same fields of the same type in the same
|
||||
order. The *names* of the fields also have to be identical but this might
|
||||
change in a future version of the language.
|
||||
*equivalent* if they specify the same types in the same
|
||||
order. The *names* of the fields are ignored.
|
||||
|
||||
The assignment operator for tuples copies each component.
|
||||
The default assignment operator for objects copies each component. Overloading
|
||||
|
|
@ -528,6 +527,8 @@ in future versions of the compiler.
|
|||
person = (name: "Peter", age: 30)
|
||||
# the same, but less readable:
|
||||
person = ("Peter", 30)
|
||||
# the same, but with confusing tuple field names:
|
||||
person = (creditCard: "Peter", id: 20)
|
||||
|
||||
The implementation aligns the fields for best access performance. The alignment
|
||||
is compatible with the way the C compiler does it.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue