C, Ocean Edition I is a semantic normalization of C. It keeps the language's computational model, its syntax, and its character, and removes the places where a programmer learns one rule and later discovers that an apparently identical construct follows another.
It derives from ISO/IEC 9899:1999, adopts selectively from later C standards, and adds one facility of its own. An array is an array. A function is a function. An address is obtained with &. A definition defines something. An object begins life with a value. Expressions execute in a defined order. Arithmetic has defined behavior.
Where to start
The specification
Thirty documents, organized to mirror ISO/IEC 9899 so the two can be read side by side.
Overview
What the collection is, how it is organized, and how to read it as an implementer or as a programmer.
Design paper
The normalization argument: what was removed, what was kept, and the litmus test each decision faced.
Differences from C99
Every difference from the baseline, in one place, with the clause that governs each.
An ordinary source file
Nothing about an Ocean Edition I file announces that a different language is being used. The differences are visible only where they matter.
#import <stdint.h>
#namespace "buffer"
struct Buffer
{
uint8_t *data;
size_t length;
size_t capacity;
};
static inline size_t min_size(size_t a, size_t b)
{
return a < b ? a : b;
}
int copy(struct Buffer *dst, const struct Buffer *src)
{
if (dst == null || src == null)
{
return -1;
}
size_t count = min_size(dst->capacity, src->length);
copy_bytes(&dst->data[0], &src->data[0], count);
dst->length = count;
return 0;
}
&dst->data[0] says that an element pointer was wanted, because arrays do not silently become pointers. min_size is a function rather than a macro. buffer would begin zero-filled even without an initializer.
The ten laws
The whole specification is an elaboration of ten laws. Where a clause is ambiguous, it is resolved in favor of the law it serves.
- Syntax means what it says.
- Expressions keep their types.
- Evaluation has an order.
- Objects begin valid.
- Arithmetic describes finite machines.
- Target differences must be real.
- Optimization does not define semantics.
- Dangerous is allowed.
- Existing C syntax is preferred.
- Fewer categories are better.
An eleventh commitment sits alongside them and is stated in the specification rather than in a paper: translation itself is deterministic. The same inputs produce the same bytes.