In a very “Thanos" moment, I decided to brush off some code I was poking at a while ago and see how far I could get myself with simple structured persistence.

Initial results are promising…

Basically, I've got a layer that's able to extract enough information from un-instantiated types and (in this case) convert it into an NSManagedObjectModel. The layer provides enough information that I could write other conversion layers, such as to bare SQLite, custom file formats, CloudKit, whatever.

Tinkering is happening here: https://github.com/davedelong/orm

GitHub - davedelong/orm: playing around with orms

playing around with orms. Contribute to davedelong/orm development by creating an account on GitHub.

GitHub
@davedelong This looks very cool, thanks for sharing. What is the `silgen_name` needed for here?

@JediMax simple answer: it lets me use a private function from the runtime the iterates over the stored properties of a type

complex answer: that attribute tells the compiler “here's a function declaration; please generate a stub for it with this particular symbol". That symbol matches one from the standard library, which gets resolved to the actual symbol at link time. That means I can effectively use a private function I wouldn't otherwise have access to.