Infinite recursion problem when trying to apply settings pattern to submodules

I’m builting a module which as a number of named submodules, eg. services.myService.foo, services.myService.bar, etc.
I’d like to try to apply the settings pattern to the options of those sub modules, eg. services.myService.foo.settings = defaultSettings in my config = {...} block.

However, since the names of the submodules are only known at eval time, I cannot easily assign the defaults or rather, doing so means iterating over services.myService and re-assigning to it, causing an infinite recursion.

Does anyone have any advice on how to tackle this specific problem?

@Infinisil hope you don’t mind, but as the father of the settings pattern, I’m shamelessly tagging you on this one :smile: