This is (should be) the exact equivalent of the Cilia code in Cpp2:
- Types
int,i32,i64,f32
- Variables
x: int = 42;x := 42;x : const int = 42;words: vector<string> = ();names: set<string> = ();contactInfoForID: map<string, ContactInfo> = ();
- Functions
multiply: (a: int, b: int) -> int = a * b;print: (a: ContactInfo) = { ...; }concat: (a: string_view, b: string_view) -> string = ...;
- Loops
i := 1; while i <= 10 next i++ { ...; }i := 0; while i < words.ssize() next i++ { ...; }for (5, 7, 11, 13) do (i) { ...; }for words do (word) { ...; }
Note
In Cpp2intand42are typically 32 bits wide, not 64 bits.
Is there really no range operator and no classical for-loop in Cpp2?