I think one can have a reasonable small computer language for which the only base type is char (one byte). Everything else is compound types of records, arrays, pointers, unions, functions, perhaps in the style of C.
Char because input and output are necessary.
One tricky bit is array indices: arrays can be maximum 256 elements long. Perhaps arrays can only be exactly 256 elements long: this solves the problem of stepping off the end of an array. The compiler can notice that certain array elements will never be used and space optimize them away. Arrays longer than 256 are multidimensional with the index broken into bytes.
Notably: no floating-point numbers, negative numbers. Use the C convention of zero/nonzero for boolean.
Integers larger than 255 are implemented as arbitrary precision arithmetic on arrays of chars. Similarly real numbers. Both of these the compiler and standard library could provide optimized versions using machine instructions.
No comments :
Post a Comment