The Translation page describes a "Hello World" example, drawn from Joe Armstrong's classic reference, Programming Erlang: Software for a Concurrent World, 2e. It presents a "raw" Elixir versions of the example, in both the source code and AST forms. Here is the Elixir AST from that page, rendered as an Elixir data structure:

iex> {:ok, str_exs} = File.read("hello_0.exs")
{:ok, "defmodule Hello do\n  def start do\n..."}

iex> {:ok, ast_exs} = Code.string_to_quoted(str_exs); ast_exs
{:__block__, [],
 [{:defmodule, [line: 1],
   [{:__aliases__, [counter: 0, line: 1], [:Hello]},
    [do: {:def, [line: 2],
      [{:start, [line: 2], nil},
       [do: {{:., [line: 3], [:io, :format]}, [line: 3],
         ["Hello world~n"]}]]}]]},
  {{:., [line: 6], [{:__aliases__, [counter: 0, line: 6], [:Hello]}, :start]},
   [line: 6], []}]}

To be continued...

This wiki page is maintained by Rich Morin, an independent consultant specializing in software design, development, and documentation. Please feel free to email comments, inquiries, suggestions, etc!

Topic revision: r5 - 11 Apr 2016, RichMorin
This site is powered by Foswiki Copyright © by the contributing authors. All material on this wiki is the property of the contributing authors.
Foswiki version v2.1.6, Release Foswiki-2.1.6, Plugin API version 2.4
Ideas, requests, problems regarding CFCL Wiki? Send us email