GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

Onymous Loops are required #49

Open coolaj86 opened 10 months ago

coolaj86 commented 10 months ago

For simplicity we'll probably require that all loops be Onymous to start, but in the future we could make it so that only broken loops are required to be Onymous.

Naming could be automated by using the name of the variable in the loop (iFor, jFor, fooFor). Minifiers could remove it when not used, of course.

Bad Example

for (let y of yyyy) {
   for (let x of xxxx) {
      if (y[x]) {
         break; // SYNTAX ERROR!!
      }
   }
}

Good Example

yloop: for (let y of yyyy) {
   xloop: for (let x of xxxx) {
      if (y[x]) {
         break xloop;
      }
   }
}