Meta-Programming and the Abstract Syntax Tree

Sep 22, 2023
1 min read 60 words Elixir
Table of Contents

AST is a data structure composed of the following elements:

Quote Literals

  • :atom
  • 1nteger
  • f.loat
  • “string”
  • [“l”, “i”, “s”, “t”]
  • {“2-element”, :tuple}

3-Element Tuples

The building block of an Elixir program is a tuple with three elements

  • variables {name, meta, context}
  • calls {function, context/meta, arguments}

“Calls” such as sum(1, 2, 3) create ASTs such as {:sum, meta, [1, 2, 3]}.

Send us your comments!