Def, like defmodule, module attributes and friends, is a side-effect. It stores information in the module table. Returned quoted expressions wouldn't quite work because we would need to collect them until the end. Check the expanded code and it may clarify things a bit.
On Sunday, October 30, 2016, Luke Imhoff <[email protected]> wrote: > I had thought that `def` returned (the equivalent [because it's really in > elixir_bootstrap.erl] of a) quoted block and in order for a `def` to count > in a loop, you'd need either a `for` comprehension, or `Enum.map`, so that > the `quote` from each `def` is concatenated together to be merged into the > caller's quoted form, but [Postgrex.Message.decode_auth_type/1 uses > Enum.each](https://github.com/elixir-ecto/postgrex/blame/ > master/lib/postgrex/messages.ex#L370-L372). How are all the `def`s > inside the `Enum.each` being preserved when `Enum.each` doesn't return the > value of each function call? This is related to https://github.com/ > KronicDeth/intellij-elixir/issues/472. > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <javascript:_e(%7B%7D,'cvml','elixir-lang-core%[email protected]');> > . > To view this discussion on the web visit https://groups.google.com/d/ > msgid/elixir-lang-core/a768af02-fdc1-45be-ad69- > e0661f79139b%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/a768af02-fdc1-45be-ad69-e0661f79139b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- *José Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Director of R&D -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4KW5Pn6%2Byzvz-9gSx6OCepwscj3WT5JO9RB%2Bo%2B4%2BcFG-g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
