buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.15k stars 31 forks source link

Loop labels #199

Closed giann closed 1 month ago

giann commented 9 months ago

To allow breaking outer loops:

while :outer (true) {
    while (true) {
        break outer;
    }
}
kfird214 commented 9 months ago

Because I think this project is drawing inspiration from zig I think it should just be the same as zig Labeled-while

outer: while (true) {
  while (true) {
    if (mabe_break_inner_loop) break;
    if (mabe_break_outer_loop) break :outer;
  }
}
giann commented 9 months ago

buzz is not really inspired by zig even though it's implemented with it. It takes more from Dart, Swift and Lua (for its architecture).

I think that starting with the label let it seem like a label could appear anywhere.