We propose syntax sugar for some of Erg's built-in subroutines, which will make Erg code look more similar to Python and be easier to use for users familiar with Python.
New if syntax
if cond:
...
elif cond2: # optional
...
else: # optional
...
desugared:
if cond:
do: ...
else :=
if cond2:
do: ...
else := do: ...
New if! syntax
if! cond:
...
elif! cond2: # optional
...
else!: # optional
...
New while! syntax
while! cond:
...
else!: # optional
...
desugared:
while! do! cond:
do!: ...
else! := do!: ...
New for! syntax
for! i in it:
...
else!:
...
desugared:
for! it:
i => ...
else! := do! ...
New import syntax
import foo
import foo as bar
import foo.bar as bar
from foo import bar
# import foo.bar # synyax error, we don't need this
desugared:
foo = import "foo"
bar = import "foo"
bar = import "foo/bar"
bar = import "foo/bar"
We propose syntax sugar for some of Erg's built-in subroutines, which will make Erg code look more similar to Python and be easier to use for users familiar with Python.
New
ifsyntaxdesugared:
New
if!syntaxNew
while!syntaxdesugared:
New
for!syntaxdesugared:
New
importsyntaxdesugared: