3 ms·
Don't take my word for it but IIRC structs are implemented as maps with a __struct__ key with the struct name, and that's used to implement checks and balances
by cess11 2y ago
Don't take my word for it but IIRC structs are implemented as maps with a __struct__ key with the struct name, and that's used to implement checks and balances at different levels of compilation, linting and so on.
In practice I find that I hardly ever need to think about things like this. A few times I've done macro expansion to peek under the hood and figure something out but that's partially Lisp damage, I could probably just as well have read some documentation.
- troad 2y agoThanks! You are completely correct: https://hexdocs.pm/elixir/main/structs.html#structs-are-bare-maps-underneath https://hexdocs.pm/elixir/main/structs.html#structs-are-bare....