News for hackers. Stuff that matters.
Re:Why I Don't Like Golang (2016) by lone_haxx0r on Thursday June 13, 2019 @02:15AM (#20172241)
> Why do we have this weird incestuous relationship between pointers and arrays? It might seem elegant at first (an array is a pointer to the first element or something like that) but actually it breaks down all over the place and can create some nasty unexpected behavior.

> Why do we need both . and -> ? The compiler is always able to know which one makes sense from the type of the variable anyway.

You're contradicting yourself in a way.

Maybe K & R thought: "Why can't arrays decay to pointers? The compiler is always able to know which one makes sense from context anyway."

I agree with the your opinion about arrays/pointers, but disagree about ./->. A programmer reading the code might confuse a pointer for a non-pointer if you conflate . and ->

There are no comments on this comment yet.