The desugar stage should wrap literals in function calls.
This is so that they are treated as objects (which is also why all literal types are capitalized in Mamba, for consistency).
For instance, in Mamba:
def a: Int := 10
print(a.to_bytes(10, "little"))
which desugars to
a = 10
print(a.to_bytes(10, "little"))
Which works fine
However, we also want to be able to one-line this:
print(10.to_bytes(10, "little"))
Which desugars to
print(10.to_bytes(10, "little"))
Which Python does not like.
So we need:
That the lex stage checks whether the point is followed by an identifier, in which case we treat this as an integer with function call.
The desugar stage should wrap the above int in int: print(int(10).to_bytes(10,"little"))
This would require annotating the type tree however, which we still don't do.
The desugar stage should wrap literals in function calls. This is so that they are treated as objects (which is also why all literal types are capitalized in Mamba, for consistency).
For instance, in Mamba:
which desugars to
Which works fine
However, we also want to be able to one-line this:
Which desugars to
Which Python does not like.
So we need:
int
:print(int(10).to_bytes(10,"little"))
This would require annotating the type tree however, which we still don't do.