It’s come up a few times recently how the following code snippets are equivalent when compiled:
def Foo do
def foo do
String.capitalize("foo")
end
end
and
def Foo do
import String
def foo do
capitalize("foo")
end
end
I’m not questioning how this works or anything, I understand the latter essentially gets rewritten to the former. However, when compiling each with elixirc
, the resulting binaries are not only different but one is a slightly larger than the other (we’re only talking a few bytes here). But when put into a mix project and compiled with mix compile
, the binaries are the same size, but still differ (no difference if compiled in dev or prod or as a release). I’m assuming this is just the @vsn
attribute, but clearly I don’t actually know.
What gives?
EDIT: If this is even a valid test, I manually set @vsn
and they still differed in mix.