local attribute symbolDef :: Pair<String Integer>; symbolDef = pair("a", 3);
Pairs are also provided as a standard data structure in core. Pairs are the first data structure that is completely unspecial–that is, it’s an ordinary nonterminal with no special language support.
The pair type is written
Pair<a b> where
Pairs are constructed using the
abstract production pair top::Pair<a b> ::= f::a s::b
local attribute priorityError :: Pair<Integer String>; priorityError = pair(3, "OH NO!");
The elements are accessed using the
if priorityError.fst > 2 then print("Error: " ++ priorityError.snd, ioin) else print("No serious errors.", ioin)
Up to date information about this data structure can be found in
Note: In future versions of Silver, we may add syntactic sugar for pairs as
(3, "OH NO!"). And similarly for types. However, this is not present yet.