The guide “Extending Languages with %ZLANG Routines” tells you all details you need to know
to extend your actual programming language.
Adding command by command it can become a long and un-handy routine.
How to do it in a clean way?
For longer sequences, you can outplace the code into another class or a routine.
But this might not be effective for midsized code segments.
In addition, the call creates an additional stack level and that's not for free.
An alternate (traditional) approach is :
Instead of adding line by line commands and it's code
you isolate each command and its code into a separate INClude file.
So what is left is just 1 single line by command and a list of activated extensions.
This example of a %ZLANGC00.mac may show a possible approach
In case you just use a few extensions you can skip this.
But I have seen extensions of several hundred lines where you get lost
even if your screen is in portrait mode.
I prefer this compact view.
BTW: #include can do more than just host #define, .. for $$$_references
This is a coding example working on Caché 2018.1.3 and IRIS 2020.2 It will not be kept in sync with new versions It is also NOT serviced by InterSystems Support !