3 ms·
I use MyDef to achieve most of features `cpy` is trying to introduce: # t.def page: t, basic_frame module: c a=10 b=a
by hzhou321 8y ago
I use MyDef to achieve most of features `cpy` is trying to introduce:
# t.def
page: t, basic_frame
module: c
a=10
b=a
$dump a, b
$ mydef_run t.def
PAGE: t
--> [./t.c]
gcc -std=c99 -O2 -o./t ./t.c && ./t
:a=10, b=10
I didn't introduce `known` keyword. If I want straight C code passthrough I simply append semicolons.
MyDef is a general preprocessor, so I need the page and module declarations to tell what file and types I am generating. It always shows the command it actually runs, so there is no magic. And it does not pretend to replace C. It always produces `.c` file for debugging or merging with existing workflow.
As long as MyDef is strictly preprocessor, it is purely complementary. If you prefer straight C/C++ at places, just use straight C. If you have questions on what MyDef syntax does, just read the C output.
It does pose some restrictions on the C I write. I do not write long statements in multiple lines and rely on my editor to softwrap the lines. Long lines are difficult to read anyway with or without splitting and soft-wrapped lines are not much difficult to read anyway. I often can avoid long lines by refactoring. In rare cases that lines still end up too long, I leave it as is to remind me that it needs further work.
Sometimes I need import third-party raw c code during a progress of refactoring or code digesting. MyDef has template construct to quote them directly.
MyDef: https://github.com/hzhou/MyDef https://github.com/hzhou/MyDef
output_c: https://github.com/hzhou/output_c https://github.com/hzhou/output_c
- abenedic 8y agoLast year I learned about MyDef. I like the basic concept, but it did not fit my use case unfortunately. I also am not well versed in Perl and at least at the time the documentation of the internals was too sparse for me, so I was not able to adapt it to fit my needs. But I do think people should look more into the idea of using preprocessors like MyDef and CPY. I, like everyone else who has the need, wound up writing my own C++ preprocessor. I think there is a lot of merit to the idea of having a low level base language which is machine independent and using a high level syntactic sugar over it.
- hzhou321 8y agoI lately do realize that to be comfortable with MyDef, one need be versed in three languages -- the language you are writing, MyDef, and Perl. People seem more welcome to the idea of having new language replacing the old rather than a solution of taking advantage of existing tools. I think this is the same barrier of Knuth's literate programming. Despite how I find how much MyDef make life easier, others will not see the same if not ready. What I am hoping for is conversation. With conversation, I can have the motivation for documentation and others can understand and the barrier may dissolve.