Remember, NAL shall be "transcodable" to C, therefore in this section, we show how things in NAL can be converted to C if removed or replaced.
->
short
, long
, int
, signed
, unsigned
char
float
, double
and long double
++
and --
_
as a symbol characterdo-while
,
union
Type[]
for
loop declaration.goto
statement.asm
statement.inline
keyword.%=
, >>=
, <<=
->
Compilers know the type of a value and hence can automatically decide whether it is a pointer or not. No need to have two separate operators ->
and .
therefore. To make code look like other programming languages, we favor the dot operator. Translating to C means automatically replacing the dot with an arrow if necessary.
NAL:
myValue = MyType;
myPointer = *MyType;
myValue.memberName;
myPointer.memberName;
C:
MyType myValue;
MyType* myPointer;
myValue.memberName;
myPointer->memberName;
short
, long
, int
, signed
, unsigned
The type int
and its modifiers short
and long
are system dependent. Additionally, the modifiers signed
and unsigned
are just cumbersome. We replace this all with built-in types:
NAL:
i8
i16
i32
i64
...
C:
int8_t
int16_t
int32_t
int64_t
...
NAL:
u8
u16
u32
u64
...
C:
uint8_t
uint16_t
uint32_t
uint64_t
...
char
In C, the type char
has the semantics of storing one character. That is usually 1 Byte but not necessary, therefore system dependent. Additionally, char
is accessible as a number which is semantically wrong. We replace the type with the following.
NAL:
letter
C:
char
A letter
is encoded in UTF-8. It is not accessible as a number, unless one uses converter methods like myLetter.ToASCIINum()
.
letter
, how about glyph
?float
, double
and long double
We replace the floating point types of C with the following:
NAL:
f32
f64
f128
C:
float
double
long double (if available as 128 bit)
And we allow for newer floating point types like f16
(which would correspond to the IEEE-754 half
type) or f128
(which would correspond to the IEEE-754 quad
type)
single
and double
was given but was quickly abandoned.++
and --
There is a prefix and postfix variant of both ++
and --
. The postfix variant has the semantics of changing the value AFTER its access. We do not allow for these variants anymore.
i += 1
is not hard to write or even i = i + 1
._
as a symbol characterDiscarded.
Idea was to disallow the underscore _
as a character in symbol names. Was smiled at by a few but frowned upon my many and overal.
snake_case
is debatably easier to read than camelCase
.m_member
would not be possible anymore.SCREAMING_SNAKE_CASE
would not be possible anymore.lowerCamelCase
and UpperCamelCase
.do-while
Replace do-while
with a new keyword dowhile
. Put condition before {}
Block.
NAL:
dowhile(condition) {
...
}
C:
do {
...
} while (condition)
do-while
completely without replacement.,
There is no need for a comma operator. Erase it without replacement.
union
TypeThere really isn't that much of purpose in having a union
type. Erase it without replacement.
There really isn't that much of purpose in having Bitfields. Erase it without replacement.
[]
Ditch the declaration with []
as it induces the usage of pointer arithmetic. Define a built-in array
type instead.
[]
type evaluates to a pointer to the first element of an array. That has no purpose if we aren't allowing pointer arithmetics anymore.Pointer arithmetics are inherently unsafe. We need to get rid of it. The only real thing which needs to be replaced it the array type []
which can be replaced by a bilt-in type array
. A special new index type []
though will be put in place this handles everything concerning iteration.
++
and --
which we will ditch as well.for
loop declarationThe general declaration of a for
loop in C like for (init; condition; step)
will be removed. Instead, for
loops shall only be used for range based loops.
for
loops.init
, condition
and step
were often misused.goto
statementThe goto
statement has no more use. Remove it completely without replacement.
asm
statementThe asm
statement shall be removed completely without replacement.
asm
.inline
keywordThe inline
keyword shall be removed completely without replacement.
Do not define multiple variables with commmas ,
.
%=
, >>=
, <<=
Ditch these three operators.
%=
makes no sense mathematically.+=
-=
*=
and /=
are usefule and simplify programming. Leave them.&=
|=
and ^=
are usefule and simplify programming flags and bools. Leave them