Open yorickpeterse opened 6 years ago
I'll try to sum up a few different models. Please correct me where i'm wrong ;)
All of these approaches are not big on information hiding.
Also:
In general i'd like to see inheritance de-emphasised or completely left out. Another aspect that we can discuss is the addition of a trait system. There is a little bit of overlap with the described record approach that allows open method definition.
@madmalik
no type safety of any kind, since all objects have the same type (the flipside of the mentioned flexibility)
I disagree, type safety has little to do with prototype OO. See TypeScript for example, and Inko uses prototype OO and the language offers type safety (through gradual typing).
One of the big benefits of prototype OO is that it's super easy to model other object systems (class based OO for example) on top of it, while the inverse is not necessarily true. I personally also found it a bit easier to wrap my head around.
@YorickPeterse
I disagree, type safety has little to do with prototype OO
Your are correct, i worded that wrong. What i meant is that the structure is more... amorphous? But I'll take a look into how typescript handles that (and of course Inko ;) ).
@madmalik Yeah, the underlying data structures are definitely less specialised. For example, for Inko it's (more or less) just this:
struct Object {
prototype: *mut Object,
attributes: Box<HashMap<*mut Object, *mut Object>>,
value: ObjectValue
}
enum ObjectValue {
Integer(i64),
Float(f64),
String(Box<String>),
...
}
We need a chapter that outlines the object model the VM will use, what the trade-offs are, etc, etc.