onyx-lang / onyx

✨ The compiler and developer toolchain for Onyx
https://onyxlang.io
BSD 2-Clause "Simplified" License
570 stars 20 forks source link

Feature request: Named Return Values #127

Closed josdelien closed 6 months ago

josdelien commented 6 months ago

Consider the following code:

// sum :: (nums: ..i32) -> i32 {
sum :: (nums: ..i32) -> total: i32 {
    // total: i32 = 0;
    for num in nums {
        total += num;
    }
    return total;
}

Having available Named Return Values already defines the return value at the procedure definition so there is no need to retype nor instantiate it in the procedure body.

brendanfh commented 6 months ago

This has been completed in #131!