Re: Haskell is our first choice for building production soft...
by mehrdadn on Monday January 11, 2021 @07:48AM
(#25728184)
I thought the complaint was about the logic duplication, not the extra keystrokes. If you want type inference you already have auto. If you want to minimize your keystrokes, you're using the wrong language to begin with, whether there's type inference or not. C++ is designed for writing software robustly, not quickly. (<-- This is not a trivial or obvious statement btw. It took me several years to grasp this. And I viewed C++ from an entirely different perspective when it finally sunk in for me that I would appreciate C++ much more if I decided to make minimizing keystrokes a non-goal.)
[ Parent
| on HN ]
Re: Haskell is our first choice for building production soft...
by secondcoming on Monday January 11, 2021 @07:56AM
(#25728265)
> If you want type inference you already have auto
or auto&&. Did you really intend to make a copy?
Re: Haskell is our first choice for building production soft...
by mehrdadn on Monday January 11, 2021 @08:01AM
(#25728307)
You probably did intend it to be a copy if you're binding it to a variable and need it to be non-const (like in the example)!
Re: Haskell is our first choice for building production soft...
by secondcoming on Monday January 11, 2021 @08:18AM
(#25728483)
Ah, but you knew that because that's how the code was written!
If it was instead
String foo = "bar";
auto baz = foo;
you don't know for sure. But the code compiles so it obviously ok!
Re: Haskell is our first choice for building production soft...
by mehrdadn on Monday January 11, 2021 @08:22AM
(#25728521)
No, I'm saying even in that case you know it was intended to be a copy. If you wanted that to be a reference then you'd either (a) just do the obvious thing which is to just use the original variable name instead of creating a new variable out of the blue for no reason, (b) leave a comment explaining why you're not doing the aforementioned obvious thing, or (c) use a self-explanatory variable name to provide the explanation instead of a comment.