The benefit of traits vs. classes is that I can add *functions* to existing objects without needing to modify a monolithic definition. The benefit of ECS vs. structs is that I can add *data* to existing objects without needing to modify a monolithic definition.
I’ve never seen a language with extensible records, so can’t say 100%. I searched and found Elm, but it just lets you define type aliases. You would need structural subtyping to make that work as traits do. Are you thinking of a specific lang?
-
-
Also, I don’t think the visitor pattern is a hack. Rustc code base uses visitors for ADTs. Visitors with default behavior mean if ADT adds a new variant, existing visitors don’t break which is valuable sometimes. Visitor vs match is open vs closed.
-
And for ECS, it’s a dynamic way of extending records. It’s hacky in the same way dynamic typing is. Basically just means every object becomes a Map<TypeId, Type>. But you could conceptually do the extensible stuff statically with enough language support.
End of conversation
New conversation -
-
-
The most experience I have is with OCaml: OCaml’s object system can be used as extensible records but they’re a bit limited because you aren’t allowed to refer to the row variable. I’ve heard Purescript does a really good job with their extensible records as well.
-
The best use of OCaml’s objects for this: GraphQL serverhttps://github.com/andreas/ocaml-graphql-server …
- Show replies
New conversation -
-
-
Clojure Protocols?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Checkout Piccola lang: http://scg.unibe.ch/research/piccola … Though I am not sure why they had to make use of channels for the coordination mechanism and whether it is orthogonal to the idea of extending records.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
cognitive psychology. PhD