Wrapping Up (Recurse Day 5)
Originally at https://notes.shaunagm.net/post/643585365627813888/wrapping-up-recurse-day-5
It’s the last day of my mini-batch, although it’s not my last day at Recurse, since there’s an active alum community I’m eager to be a part of.
I accomplished two major things on my codelibs projects today: I used a macro-generating macro to improve the templating language, turning this:
(code-template “add-story” (+ (blank “number” “n1” “A number: ”) (blank “number” “n2” “Another number: ”)))
Into this:
(code-template “add-story” (+ (blanknum) (blanknum “A custom prompt!: ”)))
Those blanknum macros are generated by a define-blank macro that can create typed blanks with a default prompt. The second blanknum is using a custom prompt. You can also reuse the values of a given blank by passing in an optional ID argument and then passing in that same ID to subsequent blanks.
I do still need to broaden the kinds of blanks users can work with beyond numbers and operators, but it’s good enough for now. I switched to added error handling. Now, when you give a non-number to a number blank or a string operator to a string blank, you get prompted to try again – rather than breaking the whole program.
I have a few things I want to finish up with this project. As I just mentioned, I want to broaden the kinds of blanks. I also want to provide the user with more information about the execution of their template, which I think requires understanding more about evaluators, which I’m in the process of researching. I also want to understand Lisp/Racket contracts, just because they seem neat.
After that, I think I’m going to switch to looking at how the concepts I’ve learned in Racket translate to Python. I know Hy is a Lisp written in Python, there’s also a couple of libraries that implement macros like macropy. And there’s a few peps related to macros and other lisp-ish concepts I want to engage with. While I do like learning for learning’s sake, it would be lovely to be able to apply this knowledge in my work as a Python programmer.