34
Root
7y

As useful as it can be, I despise auto-typecasting.

That is all.

Comments
  • 12
    Static typed languages for the win baby
  • 3
    Strong typing ftw.
  • 2
    You can have "duck typing" without auto typecasting.

    In this case it's allowing different methods to operate on the data, such as looping, slicing, indexing, counting, injecting, etc. on iterables. This isn't changing the data's type, but adding a wrapper to standard methods.
  • 1
    @Zezura auto can be pretty damn useful, especially when you're writing generic code
  • 1
    @Zezura and how is being lazy bad? And could you provide some examples as to why to bugs? Never had any that were caused by using auto (and I'm using it extensively)
  • 0
    @Zezura if I ever ended up in that situation, I'd consider redesigning my code

    Even if that's not possible, 'auto' doesn't make it any worse. You already know the type, so does the compiler. Even if you forget it: every decent IDE displays it when you hover over the variable
  • 0
    @Zezura yes, of course, but let's be honest: how often are you using that kind of variable?

    That being said, I only use it where I can save the effort of writing a type twice
    (For example:
    auto some_ptr = std::make_unique(new int[30]);
    Over
    std::unique_ptr<int[]> some_ptr = std::make_unique(new int[30]);
    ) or when iterating over a vector(or similar)
Add Comment