borgo icon indicating copy to clipboard operation
borgo copied to clipboard

fun as function keyword to line up code better

Open samuell opened this issue 1 year ago • 3 comments

Small pet peeve: I never understood why Rust (not to mention Go) didn't go with fun as the keyword for functions, so that the function name lines up with four space indentation of the code below :blush:

So instead of:

fn main() {
    let reader = bufio.NewReader(os.Stdin)

    rand.Seed(time.Now().UnixNano())
    let secret = rand.Intn(100) + 1
    // ... cont ...

We'd have:

fun main() {
    let reader = bufio.NewReader(os.Stdin)

    rand.Seed(time.Now().UnixNano())
    let secret = rand.Intn(100) + 1
    // ... cont ...

samuell avatar May 02 '24 13:05 samuell

If you are extremely careful about that alignment, consider using double spaces:

fn  main() {
    let reader = bufio.NewReader(os.Stdin)

    rand.Seed(time.Now().UnixNano())
    let secret = rand.Intn(100) + 1
    // ... cont ...

I don't recommend both of approaches since fn main() is OK, but you can propose that into fmt tool of Borgo. And don't take it too serious.

AbstractiveNord avatar May 04 '24 00:05 AbstractiveNord

I'm surprised you like that. To me, the alignment trips up my eyes so I see main as part of the function body, which of course it isn't. Having it offset makes line scanning easier in my brain.

kegsay avatar May 07 '24 08:05 kegsay

fn - is for functions fun - is not fun

Chu-4hun avatar May 07 '24 10:05 Chu-4hun