Skip to content

Records #1093

Closed
Closed
@byorgey

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

C-ProjectA larger project, more suitable for experienced contributors.L-Language designIssues relating to the overall design of the Swarm language.L-Type inferenceThe process of inferring the type of a Swarm expression.L-Type systemIssues related to the Swarm language type system.S-Nice to haveThe bug fix or feature would be nice but doesn't currently have much negative impact.Z-FeatureA new feature to be added to the game.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions