dragons-and-bytecode / comfy

Comfy - the comfortable C dialect
Mozilla Public License 2.0
1 stars 0 forks source link

Keyword 'masked' #11

Open RavenNevermore opened 9 years ago

RavenNevermore commented 9 years ago

The C namespace is tricky. This is mostly, due to the fact, that there is no namespacing.

C Prorammers have found ways around this, by prepending function declarations and typedefs with mask strings; mostly using a simple version of the header name or application name or both, to define a method or typedef uniquely.

This is a lot of unnecessary boilerplate writing work, and we can improove on that.

If you define a function or typedef as masked, comfy will internally prepend the name of the header file to the function name.

Comfy code like this, in a comfy file called somestuff.comfy:

public masked int foobar()
{
    return 42;
}

Will result into a header definition like this:

int somestuff_foobar();

and a corrosponding C file implementation:

int somestuff_foobar()
{
    return 42;
}