Rust dev, I enjoy reading and playing games, I also usually like to spend time with friends.

You can reach me on mastodon @sukhmel@mastodon.online or telegram @sukhmel@tg

  • 0 Posts
  • 339 Comments
Joined 1 year ago
cake
Cake day: July 3rd, 2023

help-circle







  • once the tool no longer works, you

    … try every trick to make it look like it works, blame everyone for not using it, blame everything for not working the way it should, break some things that are made with other tools that work for a good measure (it was their fault for being too arrogant, anyway)



  • lad@programming.devtoProgramming@programming.devOn "Safe" C++
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    5 days ago

    You got me, I decided to read the article later (I hope to, at least). But your summary looks about right, I don’t really expect C++ to become much safer than it is now, which is not very much. Should take a look at profiles, I love a good laugh

    Edit: looked up those ``profiles’', it looks like a vague and complicated proposal that will require an unrealistic amount of undertaking. But that might be seen as being in the spirit of C++










  • I mostly come to prefer composition, this approach apparently even has a wiki page. But that’s in part because I use Rust that forbids inheritance, and don’t have such bullshit (from delegation wiki page):

    class A {
        void foo() {
            // "this" also known under the names "current", "me" and "self" in other languages
            this.bar();
        }
    
        void bar() {
            print("a.bar");
        }
    }
    
    class B {
        private delegate A a; // delegation link
    
        public B(A a) {
            this.a = a;
        }
    
        void foo() {
            a.foo(); // call foo() on the a-instance
        }
    
        void bar() {
            print("b.bar");
        }
    }
    
    a = new A();
    b = new B(a); // establish delegation between two objects
    

    Calling b.foo() will result in b.bar being printed, since this refers to the original receiver object, b, within the context of a. The resulting ambiguity of this is referred to as object schizophrenia

    Translating the implicit this into an explicit parameter, the call (in B, with a a delegate) a.foo() translates to A.foo(b), using the type of a for method resolution, but the delegating object b for the this argument.

    Why would one substitute b as this when called from b.a is beyond me, seriously.