JSAbrahams / mamba

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

Function could use `:=` instead of `=>` #330

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Current Issue

I think that -> and => are a bit too similar.

High-level description of the feature

Functions would look prettier I think if they instead used the assign (:=) token:

Instead of:

def f(x: Int, y: Int := 2) -> Int => x + y

We then have:

def f(x: Int, y: Int :=2) -> Int := x + y

And if we have a larger function (or just want the body on a new line):

def f(x: Int, y: Int := 2) -> Int :=
    def z := x + y
    z ^ x

Description of potential implementation

Change parser to use := instead and remove the => token from the language (spec).

JSAbrahams commented 2 years ago

The arrow is nice in lambda functions though, hm.

JSAbrahams commented 2 years ago

An alternative would be def f(x: Int, y: Int := 2): Int => x + y