rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

In `ttype`, how does `List` differ from `Tuple`? #2

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

I assume List is homogeneous and Tuple is heterogeneous, as suggested (if not implied ?!?) by the arguments. Otherwise, they're both ordered collections, start-index 0, with duplicate entries allowed?

ttype
    = Integer(int kind, dimension* dims)
...
    | Set(ttype type)
    | List(ttype type)   --- homogeneous
    | Tuple(ttype* type)  --- heterogeneous
    | Struct(symbol derived_type, dimension* dims)
...

Proposition:

If ttype* types in Tuple denotes a sequence of types for a heterogeneous tuple, then ttypes* must denote a sequence (the ASDL is ambiguous), and the length of any tuple that conforms to the spec must be equal to the length of the ttypes*.

Remark:

The length of conforming tuples is implied by the length of the ttypes*. I consider this spec to be implied and explicit, rather than implicit, with implicit meaning "not evident from the manifest text." This spec for Tuple, once ttypes* is clarified as a sequence, is therefore acceptable under the tenet that all MASR specs must be explicit.

certik commented 1 year ago

I assume List is homogeneous and Tuple is heterogeneous, as suggested (if not implied ?!?) by the arguments. Otherwise, they're both ordered collections, start-index 0, with duplicate entries allowed?

Yes. Tuple has compile time length and (possibly different) types for each element. List has a compile time type, the same for each element, and the length is runtime (you can append and remove from it).

The documentation for all ASR nodes is here: https://github.com/lfortran/lfortran/tree/c648a8d824242b676512a038bf2257f3b28dad3b/doc/src/asr/asr_nodes and please do not close this issue until I document this there.

rebcabin commented 1 year ago

roger. Pinned the link, btw. ty :)