kalekundert / byoc

MIT License
0 stars 0 forks source link

Force layer values to be collections #14

Closed kalekundert closed 3 years ago

kalekundert commented 3 years ago

Right now, a layer value can be either a dictionary (really, any object implementing __getitem__) or a function accepting a key as an argument. The problem with the latter is that a key can be either a string or a function accepting a collection, and it doesn't make sense to use a function key with a function value. Since function values don't really add any functionality (any such function could be implemented using __getitem__, and perhaps a wrapper could be provided to help with that), I'm inclined to get rid of them. This also simplifies the API for key functions, since they could now count on __getitem__ being available.

I'll think about this some more, but for now I'll just try to limit myself to using collections.

kalekundert commented 3 years ago

The other advantage of eliminating function values is that I can then interpret callable layer values as deferred values, to be loaded when needed. This is the same way that layer locations work, so this would remove an inconsistency in the API. It would also allows use cases where layer values depend on object attribtues that aren't available at load time.