Liste des Groupes | Revenir à cl c |
On 23/04/2025 22:49, bart wrote:
No. It is in the C preprocessor language. It is quite different from C and requires special skills.Such libraries as I mentioned for embedded languages or syntax wrapping are clever, but usually impractical, unwieldy and inefficient.And as usual, I question your basis for making such wild general claims.
>Let's compare alternatives here. If I want to make a little bit of embedded language, with C macros I have :
If you want a new language, do it properly!
+ The implementation is in a language I already know
+ I can probably implement it in a few hundred lines of codeOne Brainfuck interpreter I looked at (not sure if one of those at the link below), involved 5000 lines of header code. But they can usually be directly implemented in any normal language in about 50 lines.
+ It will work with any C compiler, any target, and any C codeSome will need a particular compiler or version because they rely on some very specific behaviour.
+ It mixes freely with other C codeNot necessarily. Look at the 'datatype99' link here for example:
- Debugging it can be a bit of a painYou will need docs anyway.
- Complicated things can get a bit ugly with macro tricks
- C macros are not Turing complete (no loops, recursion, etc.)
Doing it "properly" means :
+ The language can support anything I want it to
- I have to design a whole language
- I have to document a whole language
- I have to implement a whole language and all the toolsThat is going to be a problem anyway if you have this mysterious-looking syntax in the middle of a C file.
- It only works for the targets I bother supporting
- No one else can use it without all the tools
- It has to be a complete language on its own
- Integration with other code is a PITA at best
- The implementation in C probably uses lots of macros...Who said devising a language was easy? But a CPP-based one will be poor. Here's a comment from the Ferdi265/BF interpreter at that link:
The suggestion that making your own language and tools instead of a macro library is clearly absurd.
While not my thing, I was thinking of something like Racket.Or use a more appropriate base language.That is sometimes a much better option.
Les messages affichés proviennent d'usenet.