JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Add operator for calling unsafe Python code #160

Open JSAbrahams opened 4 years ago

JSAbrahams commented 4 years ago

Current Issue

We can circumvent much of the type system by simply calling unsafe Python code.

High-level description of the feature

Add an operator that signifies we're calling Python code. Such code may, to left of the operator, be considered unsafe. This means that we may get runtime errors caused by Python.

Everything right of the operator should be (type) safe "Mamba" code. i.e.

# unsafe function presumably returns an integer
def a: Int! := unsafe_function(1, 4)!

# a now has type int!, meaning that we assume it has type int, but this cannot be guaranteed
print(a)

I would suggest using the ! token, similar to Kotlin, which also uses this token to signal calling unsafe Java code.

Description of potential implementation