hissp icon indicating copy to clipboard operation
hissp copied to clipboard

Add tutorial for macros

Open gilch opened this issue 5 years ago • 2 comments

I could certainly walk through re-implementations of some of the basic macros. Should probably include nested templates, like defmacro/g/defmacro!. See if we can make the Lisp-2 macro work.

gilch avatar Nov 25 '20 03:11 gilch

The first lesson is up #78.

gilch avatar Jan 06 '21 18:01 gilch

There are still a number of TODOs in the macro tutorial source. Some of them seem outdated. The first two already cover a lot of ground, so additional lessons would have diminishing returns, but there are a few important techniques that still deserve mention. Some advanced macro techniques also applicable to Clojure or Common Lisp are perhaps already better covered elsewhere. Perhaps at most they deserve a link. However, some techniques are unique enough to Hissp (or Lissp) that they merit further tutorials.

In particular:

  • The use of Extras. Maybe not stable enough, and already covered in the quickstart. Unique to Lissp.
  • Metaprogramming the _macro_ object by implementing its __getattr__ (e.g. the Lisp-2 technique). Unique to Hissp.
  • Pre-expansion and code walking. The original plan was for a code-walking yield macro. I'm no longer certain if that is feasible, but we might be able to do better than Ensue. I limited Hissp to two special forms in part to make this kind of thing easier.
  • Destructuring fn. I put a lot of thought into lambda's parameters tuple to make this work better. This is pretty much unique to Hissp.

And easier lessons may be required to lead up to these.

gilch avatar Apr 10 '22 05:04 gilch