Hacker News new | past | comments | ask | show | jobs | submit login

It does - when I call

    Func( foo, foo);
I don't want foo to be loaded twice.

Theres also the `const` on the function itself. If I do:

    struct Foo {
        int GetVal() const {
            return Val;
        }

        int Val
    };

    void Bar(const Foo& f){
        int val1 = f.GetVal();
        int val2 = f.GetVal();
        assert(val1 == val2);
    }
This is not guaranteed for a variety of reasons. This means that there are many optimisations that are just unavailable because of const, and there are guarantees that on first glance you expect to be true, but arent.

I understand why, we don't need to go into it, but its a mess that const doesn't actually mean constant.

It just means you've opted into coloured functions [0]. It's not quite as painful as async functions in js, but all the same arguments apply.

[0] https://journal.stuffwithstuff.com/2015/02/01/what-color-is-... t




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: