C2 forum
General Category => Implementation Details => Topic started by: lerno on October 28, 2018, 11:36:12 AM
-
First a quick note: I think the documentation is missing keywords. At least "func" isn't there and there might be more.
Anyway, I note that the types ixx and uxx are keywords in the language. Is there any reason why they are tokens instead of identifiers? Or is this just a consequence of borrowing from clang (c) where they are indeed tokens?
Furthermore, there are today keywords for things that are function lookalikes but are actually more like macros:
- elemsof
- enum_min
- enum_max
- sizeof
If the suggestion to use @ to indicate that the compiler does something special at this point, we could swap them for
- @elemsof
- @enum_min
- @enum_max
- @sizeof
This makes them reseved macro names rather than function names (I personally always found the sizeof operator a bit weird since it looked like a function but was a keyword)
The current list has 46 keywords. Eliminating the types and moving the above mentioned things to the "@ namespace", we get that down to 30.
-
Indeed, I've updated the documentation
elemsof() is implemented as a macro is C, but just the same as sizeof() in C2 (since this macro is implemented in so many programs).
There are just a few of these specials, so I don't think every C2 programmer will know them, just like sizeof() in C. Instead of a keyword
we could place them inside the c2 module, so you can access them with c2.sizeof() or sizeof() (if you import c2 local).