2 ms·
Ah yep, dictionaries are pretty similar to objects in this sense. Mostly just a matter of notation. I often use dictionaries as a poor man's object. It could b
by dhotson 18y ago
Ah yep, dictionaries are pretty similar to objects in this sense. Mostly just a matter of notation.
I often use dictionaries as a poor man's object.
It could be kind of cool to have proper objects with methods to interact with them. You could use code reflection to figure out what verbs are supported.
- silentbicycle 18y agoNot objects, structs though. The syntax for (and ability to mix types in) Python dictionaries make them really convenient for this sort of thing. Of course, you can have references to functions in dictionaries and use them for dispatch. I think that's how the OO system is implemented, anyway. I'm only slightly acquainted with Lua, but it looks like it gets a lot of expressiveness out of having a similarly useful dictionary-like type. I think it calls them 'tables'.
- dhotson 18y agoOh cool, I think that's similar to how JavaScript 'objects' work. I've heard that it's not that difficult to do object oriented stuff in plain C using nothing but structs and function pointers. I can imagine the syntax would be a pain in the ass and ugly as hell though. :P I'll have to take a closer look at Lua.. have you used it much before?
- silentbicycle 18y agoNope. I read about it and played with its interpreter some, but its niche isn't really very relevant to me. It seems designed for when you want something flexible and Python-like to embed in a C program, but you need something minimalistic because memory is really tight. It looks like a pretty well-designed language, though. It's small and clean enough that one could probably memorize the entire language.