Opened 9 years ago

#3930 new enhancement

Better tuple access functions in MetaModelica

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: Future
Component: MetaModelica Version:
Keywords: Cc: Adrian Pop

Description

To access elements in a tuple you currently need to either use pattern matching or one of the Util.tupleNN functions. It would be nice if there were some way of accessing the elements using an index instead, e.g.:

tuple<Integer, String> tup = (1, "hello");
String s = tup[2]; // or some other equivalent syntax.
// Maybe also a function to allow function pointer stuff:
Integer i = tupleGet(tup, 1); // or tupleNth, or whatever.

This would be more flexible and possibly more efficient than using the Util.tupleNN functions, and would also make it possible to use enumerations to name elements:

type MyTupleNames = enumeration(index, name);
String s = tup[MyTupleNames.name];

An issue with this is that each tuple element has its own type, so type checking becomes a problem.

Change History (0)

Note: See TracTickets for help on using tickets.