Closed
Description
Records were mentioned in #1087 as a way to represent imported modules. They would also be a cool, handy feature on their own. Records can make it very convenient to package and work with "objects". For example, compare:
-- with records
f : [size : int, name : text, action : cmd unit] -> cmd unit
f r = if (r.size > 10 && r.name != "base") { r.action } {}
-- without records, ugh
f : int * text * (cmd unit) -> cmd unit
f r = if (fst r > 10 && fst (snd r) != "base") { snd (snd r) } {}
However, records have one very big downside: inferring record types requires some fancy type system features such as e.g. subtyping and row polymorphism. A simple alternative could be to just give up on inferring record types and require type annotations (would probably require #10).
I do not know whether adding records would be worth it, or what the right tradeoffs would be if we did add them. For now, just adding this issue as a placeholder for discussion.
Metadata
Assignees
Labels
A larger project, more suitable for experienced contributors.Issues relating to the overall design of the Swarm language.The process of inferring the type of a Swarm expression.Issues related to the Swarm language type system.The bug fix or feature would be nice but doesn't currently have much negative impact.A new feature to be added to the game.