More C3 Idioms
Some examples of “idiomatic” C3 code, or, code that follows patterns from the standard library.
Types in C3 do not need to be prefixed with their module namespace, and it is recommended not to namespace types unless there is a name conflict.
Using types without namespacing can make your code more readable, especially with longer module names, since you can instantly tell something is a type without needing to read the module path first.
If writing a library, the names of public types should be prefixed with a shortened
form of the library or module name to show what library it came from and prevent
possible name conflicts from using a generic name like File, Window, or Rectangle.
Functions that allocate should take an Allocator as the first parameter and
use the allocator:: functions such as allocator::malloc instead of mem::malloc.
Any intermediary allocations should be made on the temp allocator inside
an @pool block.
If there is an allocator that is intended to be used by default then the
Allocator should be the final parameter and use a default value instead of
hardcoding the allocator inside the function.
This pattern both shows which functions make allocations (and thus need their return values freed) due to the explicit allocator parameter and allows users to pass an allocator of their choice.