Author Topic: Keywords keywords keywords  (Read 10006 times)

lerno

  • Full Member
  • ***
  • Posts: 247
    • View Profile
Keywords keywords keywords
« 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.

bas

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: Keywords keywords keywords
« Reply #1 on: November 07, 2018, 10:28:32 AM »
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).