Object Systems 2018-11-16

By Max Woerner Chase

In this post:


Another late Friday post...

On further reflection, it's a bad idea to attempt an "everything is an object" system in Lua without creating an entire runtime to deal with it. As such, I'm going to restrict the scope of the current idea/project to dealing with wrapped values, basically putting forward composition as much as possible. There are two special cases I want to account for in my current ideas on accmplishing this stuff. One is that ideally there should be a fast path for objects that wrap a single value. The other is that it should be possible to create singleton objects that don't have a constructor or track internal state. It'd also be nice to memoize the wrapping functionality. I'll see how far I can get without parametric types, but I'll probably be thinking about introducing them, we'll see.

So, I'm currently focused on generic wrapping, which means I'll relax the "everything is an object" stuff at least enough to mitigate the need for specific boxed types.

Here's what I have in mind for all of this stuff:

After the values are returned from the constructor and wrapped up, the wrapped value and the type are associated with the new object.

Let's look at the kind of stuff I want to prototype with this whole idea:

Basically, I want to prototype some of the stuff I've been trying to do in Rust, and try actually applying it to something before trying to optimize.


Next time, I'll try to get the basics of all of this working.