Differences to regular C

Here is a list of differences to regular C.

  • We don’t support the preprocessor. Instead we will provide first class concepts for all the various use cases of the C preprocessor. This avoids some of the chaos that can be created with the C preprocessor.
  • While we generate header files, we don’t expose them to the programmer in MPS. Instead, we have defined modules as the top-level concept. Modules also acts as a kind of namespace. Module contents can be exported, in which case, if that module is imported by another module, the exported contents can be used by the importing module.
  • We have introduced a specific Boolean datatype. Integers cannot be used as Boolean. in all of to call legacy functions, the wrapper construct will be provided.
  • In the switch statement, we don’t use the annoying fall through semantics. Only one case within the switch will ever be executed, since we automatically generate a break statement into the generated C code.
  • The language has direct support for test cases (as module contents)
  • Array brackets must show up atter the type, not after the variable name
  • The * for pointer types must show up after the type, not before the identifier (i.e. int x vs. int x)
  • At this point a local variable declaration can only declare one variable

There are various reasons for these differences. For some of them, we feel we are compensating weaknesses of C (int vs boolean). For others, we exploit the capabilities of MPS and the generative approach (modules). Yet others just make our lives as implementers more pleasant (arrays and pointers after type instead of variable name).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s