💾 Archived View for freeshell.de › gemlog › 2022-09-13_White_space.gmi captured on 2023-04-19 at 22:52:50. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

White space

(Obvs differs from Whitespace!)

I read that Go enforces code layout, so I'll probably never use Go. I'm not bothered where the curlies go or whether indentation is tabs or spoaces. It makes no difference. But if I can use whitespace to make structure explicit, I'm all for it.

Consider a C-style function:

int someFunc(char* someStr, int someInt, someStruct* magicBeans){
    // do stuff
}

Often the list of parameters is pretty un-readable. And here there are really two lists, one of types and one of names. You can make that structure pop out at you:

int someFunc(
    char*       someStr,
    int         someInt,
    someStruct* magicBeans
){
    // do stuff
}

Here's another example of hidden lists. There's one of member names and one of values...

record.name = "Alex";
record.wibbleIdentifier = 23;
record.foo = bar;

...so let's make that visually explicit:

record.name             = "Alex";
record.wibbleIdentifier = 23    ;
record.foo              = bar   ;

I'd say that the punctuation that the compiler requires is almost melting away, leaving names of things and values

So just leave the code where I put it! Sadly I may be alone in this view.

Addendum

As a thought experiment, imagine a langauge which avoided punctuation altogether and just used names and values. Is that even possible?

#CodeLayout

back to gemlog