3 ms·
Wouldn't record literals with open recursion lead to a design with much less semantic duplication?
by jules 11y ago
Wouldn't record literals with open recursion lead to a design with much less semantic duplication?
- gavinking 11y agoWell I guess it's not extremely clear to me how a "record literal with open recursion" isn't essentially the same thing as a "class".
- jules 11y agoA record literal is an expression that creates a value. A class would then be a function, as chriswarbo suggests.
- gavinking 11y agoI understand, but once you start taking into account other requirements, like the ability to functionally decompose construction of this record, you will wind up with something that looks painfully similar to a class in Ceylon.
- jules 11y agoCan you elaborate on that? Since in this model constructors are just functions you can of course define multiple constructors that may or may not call each other.
- gavinking 11y agoWell the issue in my mind is how to functionally decompose construction of a record. You have to come up with some way to express a "partial" record, and then "augment" it with new members. I'm trying to say this without using the word "inheritance" ;-)
- jules 11y agoYes, sure, you need a construct to extend a record. All but the simplest record systems have this though.
- gavinking 11y agoRight, so at that point, as I say, there's really not much daylight between "class" and "record". The difference being that a class protects its initialization logic (favoring modularity), whereas a record opens it up (favoring flexibility). Ultimately I see them as much more similar than they are different.
- jules 11y agoThe difference is that a class combines several things into one construct (initialization, type definition, naming) that are separate with records. This is also what causes you to need such an elaborate design for constructors.
- gavinking 11y agoWhat I'm trying to say is that I don't think that the total complexity or total expressiveness is ultimately much different. You trade class types + interface types for record types + named structural types. You trade class inheritance for record extension. You gain a tiny little bit of flexibility via structural typing - but in my opinion much less than is often claimed, since in all these languages so-called structural types are only partially structural - and you lose some power at the tooling level (refactorings are no longer guaranteed to work). You gain a bit of flexibility by decoupling initialization into a function, but you also gain a bit of verbosity and lose a little bit of modularity. Ultimately it's a bit of a wash and honestly I would probably be almost as happy with OCaml or Rust or something like that as I am with Ceylon. I think both systems work well and are intellectually consistent. I don't think either is clearly superior to the other.
- jules 11y ago