While parsing a bracketed expression, we could recursively switch back to the base Hebigo parser when encountering a macro character that Python doesn't use, like !, until we finish the next Hebigo expression, then place the result of compiling that back into the Python string we're building. This would effectively be a builtin reader macro. For example,
def: fibonacci: n
:@ functools..lru_cache: None # Qualified identifier in decorator.
if: (n <= 1)
:then: n
:else: (!fibonacci:(n - 1) + !fibonacci:(n - 2))
Maybe a bad example, since Python's expression syntax can handle this part fine.
:else: (fibonacci(n - 1) + fibonacci(n - 2))
But suppose we needed a macro.
(!macro:spam + !macro:eggs)
We'd currently have to do something like
!let: :,: s e
:be hebi.bootstrap..entuple: macro:spam macro:eggs
(s + e)
or
operator..add: macro:spam macro:eggs
On the other hand, we might want to encourage using hotword expressions instead of Python expressions, because it's much easier to write macros to work with those.
While parsing a bracketed expression, we could recursively switch back to the base Hebigo parser when encountering a macro character that Python doesn't use, like
!, until we finish the next Hebigo expression, then place the result of compiling that back into the Python string we're building. This would effectively be a builtin reader macro. For example,Maybe a bad example, since Python's expression syntax can handle this part fine.
But suppose we needed a macro.
We'd currently have to do something like
or
On the other hand, we might want to encourage using hotword expressions instead of Python expressions, because it's much easier to write macros to work with those.