← Back to context

Comment by Someone

3 hours ago

https://miniscript.org/files/MiniScript-QuickRef.pdf:

“A class or object is a map with a special __isa entry that points to the parent. This is set automatically when you use the new operator.

  Shape = {"sides":0}
  Square = new Shape
  Square.sides = 4
  x = new Square
  x.sides  // 4

So

- Shape is a map (it is created using the syntax defined earlier, using a literal string as key)

- Square is a class?

- x is an object?

Or is this language prototype based? If so, why mention the word “class”? If not, isn’t it confusing to use “new someMap” to create a class and “new someClass” to create an object?

I also find it curious to see that division is defined on lists and strings. What would that mean?

Edit: reading https://miniscript.org/files/Strout_iSTEM-Ed2021.pdf, it is prototype based. That’s interesting for a teaching language.

Yeah, I guess it’s prototype-based and the authors meant classes are indistinguishable from objects. And they all are just special cases of map.