In #colony#colang, bytes type is really not required as primitive type. str type should exist since it is unicode and mostly used by developers. However, bytes can be represented as Array<u8>.
Since #colony#colang is GC'ed using Reference Counting, refcount, or RC, we can introduce special kind of references called "immortal references" and an example is `bytes: type = Array<u8>`. This should be implementation detail and not exposed to developers.
Immortal objects are GC'ed. So, incref or decref is almost fast as NOP. It will need to check flag on object and determine if object is immortal. Immortal means it stays forever alive while programming is being executed.
Immortal objects without RC field are primitive types such as bool, ints, floats, and short-sized strings (less than 120bits).
All builtin types objects should be immortal. Ref counting them makes no sense. Imagine constantly recreating `bytes: type = Array<u8>` every time we encode str to bytes.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
In C implementation of #colony#colang, every object has two fields, 64bit kind and 64bit value. Which means that we spend 2 64bit registers just present single value in case of primitive values such as bool, u8, u32, u64, i64, f64.
In case of GC'ed objects such as generic, array, dict, struct, union, and so on, we need indirection because these "structures" simply require more space. But in case of everything above, I think we can do better.
Perhaps, for abstract types we can move RC in "type" field, and limit mac RC count to 2 **56 which is quite large number, and currently good enough for our GC needs.