Macro and Other Updates
Erie can now handle some basic macros. Very basic. It only does macro expansion once, and it doesn’t correctly call Erie definied functions from within a macro.
Despite those limitations it can correctly compile this module. However, cons
and +
aren’t properly defined as functions, so executing either one_plus_two
or the_first
will fail.
(defmodule Core)
(defmacro infix [ast]
((lambda [list]
[(Elixir.Enum.at list 1) (Elixir.Enum.at list 0) (Elixir.Enum.at list 2)])
(Elixir.Enum.at ast 0)))
(def one_plus_two []
(infix (1 + 2)))
(defmacro a_list [ast]
['cons 1 nil])
(def the_first []
(Elixir.List.first (a_list nil)))
I’m pretty happy with the progress I’ve made so far on Erie, but there is obviously a lot more to do. Some possible next steps are:
- REPL
- Types
- Standard library
- More advanced macros
- Syntax highlighting
More advanced macros can definitely wait. A standard library will be very handy, but it’s not preventing me from writing Erie right now. Types are going to be very important soon, but I think a REPL will have the biggest impact. The ability to write small bits of Erie and execute it immediately will help shape the ergonomics and dictate what should be included in the standard library.