madfish-solutions / sol2ligo

⌨️ 🔮 Transpiler from Solidity to PascalLIGO language
https://madfish-solutions.github.io/sol2ligo/
MIT License
70 stars 4 forks source link

Support break op #29

Closed KStasi closed 4 years ago

KStasi commented 4 years ago

break should stop loop. It doesn't have a direct analog in Ligo so some another solution should be proposed

konchunas commented 4 years ago

According to https://ligolang.org/docs/language-basics/loops/#while-loop

⚠️ The current PascaLIGO while loop has semantics that have diverged from other LIGO syntaxes. The goal of LIGO is that the various syntaxes express the same semantics, so this will be corrected in future versions. For details on how loops will likely work after refactoring, see the CameLIGO tab of this example.

So ReasonLIGO supports both break and continue operation no problem.

let aux = (i: int): (bool, int) =>
  if (i < 100) {
    continue(i + 1);
  } else {
    stop(i);
  };

Maybe we should consider switching to Reason dialect?

konchunas commented 4 years ago

break was totally removed from every dialect of LIGO. We may failwith on break for better or for worse