corx
A statically typed, general-purpose programming language, crafted for simplicity and performance.
"Trust the programmer" - corx
# typeof
Operator (approved partially)
Purpose: Allows determining the type of a value or variable at compile time or runtime.
Metadata Needed:
- The actual type of the variable or value (e.g.,
int, float, string
).
- Whether the variable is a pointer, reference, or array.
Overhead: Minimal if handled at compile time, but runtime type determination may require embedding type
information in variables or objects.
# len
Operator (dropped for now)
Purpose: Retrieves the size of arrays (both static and dynamic).
Metadata Needed:
- For static arrays: Size is known at compile time (e.g., from
int arr[10]
).
- For dynamic arrays: Size must be stored alongside the allocated memory.
- Example: Allocating extra bytes before the array to store the size.
- Metadata format:
[size | array elements...]
.
Overhead: A small fixed cost for storing size metadata for dynamic arrays.
# Variadic Functions (approved)
Purpose: Support mixed or same-type arguments with safety and ease.
Metadata Needed:
- Length: Number of variadic arguments passed.
- Types: For mixed-type variadic arguments, the type of each argument must be stored.
- Example:
render(2, 42, "Hello")
would require storing [int, string]
as
type metadata.
Overhead:
- Storing the length of arguments: Fixed size, negligible cost.
- Storing types for each argument: Small additional cost, proportional to the number of arguments.
- If arguments are passed as pointers, type metadata could reference these directly without duplicating.