2 ms·
It's closest in spirit to Steve Yegge's "Universal Design Pattern": http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html http://steve-yegge.blo
by sillysaurusx 6y ago
It's closest in spirit to Steve Yegge's "Universal Design Pattern": http://steve-yegge.blogspot.com/2008/10/universal-design-pattern.html http://steve-yegge.blogspot.com/2008/10/universal-design-pat...
Basically, the core data structure is a special kind of dictionary. When you fetch a key, if the dict doesn't have it, it recurses to a list of "parent" dictionaries that you can specify.
I don't know Rust's traits / trait objects, but the observation of the paper is that you can break apart your interfaces into a "traits dict".
E.g. dog traits would have bark and pant, and would have a parent link to animal traits, which has eat and sleep, which has a parent link to entity traits, which might have position / collision model / etc.
This lets you mix and match functionality at runtime, very similar to adding classes to Python's __bases__ list (which I'm quite find of for mixin purposes: https://github.com/shawwn/mtftorch/blob/8b680ab86603a771804494865fa360e7934e229b/mtftorch/_C/__init__.py#L449-L476 https://github.com/shawwn/mtftorch/blob/8b680ab86603a7718044...)
- nerdponx 6y ago> Basically, the core data structure is a special kind of dictionary. When you fetch a key, if the dict doesn't have it, it recurses to a list of "parent" dictionaries that you can specify. Sounds like Lua metatables, as well as Python classes. Also.. what's this Mftorch thing? Your own library?