Object Systems 2018-11-18
In this post:
- It exists now
I put together most of the functionality I'd decided on, with the main missing bit being validation. By referring back to a previous, more complicated system, I was able to get the tricky bits done, though I suspect there's some way to make it more parsimonious. I then put together one of the examples of "things I want to try to do".
I started trying to document it, and that's kind of rocky. It's a combination of "this file is big and messy and contains some things that should be their own modules", "I'm not sure how best to express the concepts in terms LDoc understands", and "I have so godawfully many tabs open that LDoc's documentation stutters nauseatingly when I scroll it".
Let's look at what I have:
- read is a utility function that could probably stand to have a better name. It's used to convert a method that takes count wrapped values after self, into one that takes a wrapper after self.
- singleton is a utility function that I haven't used yet, which creates singleton constants that hook into the object metamethod dispatch system.
- type is a functable that takes a constructor, followed by a sort-of metatable, and returns a similar functable that uses the provided constructor to create objects with behavior controlled by the sort-of metatable.
- typeof is a utility function that returns the type of a value, with respect to this object system. typeof(type) == type
I added some more functions that I haven't tested out, and therefore I'm not really sure about.
Missing functionality:
- No validation around method return values
- Actually, the method logic is half-implemented, at best (UPDATE: I did it)
- singletons shouldn't be given their wrapped values, which conceptually do not exist
- Actually, actually thinking about singletons has me thinking they need some special-case logic everywhere, which isn't really much of a hardship.
- But I'll hold off on that until I actually try to use them. I mean, maybe the way to go is to just use read(0, ...)
I think what I need to do is try to apply this library to basic code challenges. And sleep. I really need to sleep.
Next time, what I thought of this week.