Unofficial Hacker News companion — get notified on comment replies, and more.

In C++, = default and {} are not the same constructor (opens external site)

131 points by surprisetalk 6 days ago | lemire.me | 202 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (1)

  1. Objective-C plays it fast and loose here. It doesn’t enforce object initialization, hence client code including subclasses can create and use uninitialized instances.

    Smalltalk is even worse, but it also has the philosophy that anything can be patched at runtime, so it kind of is in line with that.

    This is basically about static type safety.

    You could in principle enforce proper initialization and encapsulation by static analysis requirements instead of by a dedicated language construct. The latter is traditionally more efficient however, and arguably makes the code more explicit about its intent.