Comment

Comment by stormbrew

> A reference is a pointer that is never null.

This isn't even theoretically true:

    void blah(int &x) { x++; }

    int main() {
      int *x = NULL;
      blah(*x);
    }
You can definitely write a smart pointer that more or less provides some kind of guarantee about this (with a combo of runtime checks and typefoo) but references only provide a guarantee that they are not statically initializable to null, which is very different.
parent stormbrew 4 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton