What You've Learned
This chapter demonstrated how to create DSLs in Lisp. You learned the following:
When you need to do some weird programming for a very specific domain, Macros are a great solution. With them, you can create your own DSL.
Often, it makes sense to first write a helper function for a macro (like
print-tag), and then write a macro (liketag) to add improvements that only a macro can provide. These improvements usually involve being able to access the code with a clearer, and often safer, syntax.You can mix DSLs with regular Lisp code, which gives you a lot of power.
DSLs are useful when you need to write very specific code—whether it’s code for a web page, code that draws a picture, or code that builds special game commands.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access