News for hackers. Stuff that matters.
Re:Elixir RAM and the Template of Doom by phlakaton on Tuesday April 26, 2016 @03:30PM (#11574828)
I'm just starting to learn Elixir and Phoenix. Here are two little bits of "magic" that have thrown me for a loop so far:

1. @var's in templates are not module attributes (though they do seem to be convenient!)

2. The form for `use` is different in Phoenix than it is in Elixir proper – instead of passing opts, you pass an atom that selects the implementation of __using__ you want. (This bit of magic makes no particular sense to me – why wouldn't you just use a submodule, say MyApp.Controller, that has the correct and single __using__ attached?)

Re:Elixir RAM and the Template of Doom by true_religion on Thursday April 28, 2016 @02:55AM (#11586941)
> The form for `use` is different in Phoenix than it is in Elixir proper – instead of passing opts, you pass an atom that selects the implementation of __using__ you want.

This isn't really true. If you check out the ExUnit, you can pass something like "use ExUnit.Case, aysnc: true" and it'll setup your module to run tests asynchronously. You can pass any atom/value combination into use.

HTTPoision.Base, and ExAws to name a few other projects also have the convention of passing options into __using__.

To me, the confusion comes from the fact that the Elixir get-started documentation doesn't say anything about this. It is however listed in the Kernel forms that "use Module" actually just translates to Module.__using__([])

Re:Elixir RAM and the Template of Doom by phlakaton on Saturday April 30, 2016 @07:35PM (#11604136)
That's the point though - in those cases, you're passing a keyword list, a set of options, instead of an atom which acts as a selector. IIUC the Web module violates the convention attached to and documented for `use`, which to me, who was already wrangling with the subtleties of what `use` does compared to, say, Ruby's include, or Elixir's alias/import, was a bit of confusing (and relatively unconventional) magic.
Re:Elixir RAM and the Template of Doom by colbyh on Tuesday April 26, 2016 @08:02PM (#11576819)
you can define `__using__` any way you want, and phoenix's default isn't technically any different. it's just a convention that you can choose to use or not, personally I try to rip out a lot of what the `web.ex` file does because I like being more explicit.