ZoKrates icon indicating copy to clipboard operation
ZoKrates copied to clipboard

Use more modern syntax for control flow

Open Schaeff opened this issue 3 years ago • 1 comments

Abstract

Introduce a more modern syntax for control flow

Motivation

for do endfor and if else fi look a bit outdated.

Specification

This is tbd, but two candidates are:

  • indentation based à la python, then for loops are exited by removing one indentation. This is potentially tricky to implement in the current state of our parser
  • blocks à la {rust, js, C, ...}. This would be another move away from python, but it's a pretty widespread way to scope things and it seems to be ok to implement (functions and for loops are already treated as scopes)

For if-else, blocks remove the need for fi, didn't look into the python case yet.

Backwards Compatibility

Very probably a breaking change.

Schaeff avatar Apr 08 '21 17:04 Schaeff

I think the safest route to go is with curly braces as it is widely accepted. Python-like indentation is sometimes annoying (with deeply nested conditionals etc), and its worthiness is still debatable.

dark64 avatar Apr 12 '21 13:04 dark64