Hey Pedro,
In Elixir, data has no behavior associated with it. Data is just data. Functions are where the behavior is encapsulated. So, a feature like "dynamic access" fields like the one you propose would clash with this core idea. There are also some other issues:
- Having Foo.calculate_b(a) is also explicit and predictable, compared to having foo[:b] be dynamic.
- What if you had side-effects in the access function, like changing some state or writing to a file? Then, every call to foo[:b] would perform those side effects implicitly.
- The particular example you provided wouldn't work, since you can't reliably have function values at compile time (like the fn used there).
Thanks anyways for the proposal!