Let’s get loopy!
for <identifier> in <container> <body>;
This form of the for loop mimics C++’s ranged for loops. It’s purpose is to easily loop over built-in containers like dynamic arrays and views.
In effect, it binds <identifier> to a reference to each element within <container>.
Emits code in the form of:
NOTE: Should we cache <container> expression, or evaluate it multiple times?
cfor
{
iter :: <container>.data;
end :: <container>.data[<container>.size];
};
iter != end;
iter [= 1;
{
<identifier> :: @iter;
<body>;
};
for <initialiser>; <condition>; <increment>; <body>;
This form of the for loop mimics a C for loop exactly.
Emits code in the form of:
{
<initialiser>;
while <condition> {
<body>;
<increment>;
};
};