I love pointers

I love pointers

  1. 1 week ago
    Anonymous

    Same. They are good for connecting data parts but I also like to use them as identifiers (the address) nstead of coming up with my own. I found the approach to be more flexible.

    • 1 week ago
      Anonymous

      please explain more how you use them as identifiers.
      I seriously hope you are not using them as persistent identifiers.

      • 1 week ago
        Anonymous

        It's mostly when dealing with set-like containers (key-value is the pointer type), or acquiring some associated data/object. For persistent stuff like serialization, what I do is to have some hierarchical format that describes which data parts are being referred to by it, usually by simply reflecting the code itself so you have struct layout saved alongside data in some associative manner. From that I reconstruct data/object during deserialization using the saved (now invalid) pointers as ref. keys to bind newly created stuff together. It might sound complicated but once you have that done you no longer need to really bother with even persistent IDs anymore, the code itself does your job for you.

        • 1 week ago
          Anonymous

          ok, when you reserialize the data, do you end up having to overwrite any that is not directly related to what you changed?
          what about scaling to multiple machines?

          • 1 week ago
            Anonymous

            It basically looks like this.
            @0x0 "MyStruct": {
            @0x0 "int x": 1,
            @0x4 "int* ptr:" 0x1000
            }

            @0x1000 "int": 2

            @0x20 "Storage" {
            @0x20 "MyStruct[20] myStructs":{{2, 0x1000}, {4, 0x1000}}
            }

            >do you end up having to overwrite any that is not directly related to what you changed?
            Is that related to the pointer talk? I feel like this is a separate issue where you basically just need some data versioning.

            >what about scaling to multiple machines
            You mean 64 vs 32-bit address map? It not really a problem if the deserializer just recreates the data and uses file addresses as a reference keys.

  2. 1 week ago
    Anonymous

    I don't

    • 1 week ago
      Anonymous

      why not?

      • 1 week ago
        Anonymous

        I lied
        They absolutely have their uses and I like them (for now), but I rarely use c++ and haven't shot my leg off with it yet

    • 1 week ago
      Anonymous

      >void *

      how does that work?

      • 1 week ago
        Anonymous

        it's a pointer to memory with no defined type

        • 1 week ago
          Anonymous

          when would you ever use this?

          • 1 week ago
            Anonymous

            when you have a function that allocates/works with data of an arbitrary/unknown type, like malloc, which return a void pointer
            I've only had to use it a couple of times in my own code tho, usually when working with weird non standard datatypes

            • 1 week ago
              Anonymous

              I vaguely recall using it when I wanted to do pointer offsets that did not align with the size of the datatype I was working with
              Though for the life of me I can't remember why I wanted to do that

              • 1 week ago
                Anonymous

                Meant for

                when would you ever use this?

          • 1 week ago
            Anonymous

            one example of where it's commonly used in c is when you have "userdata". For example if a function takes a callback function and you want to be able to pass your own data to the function. Or if there is a struct in a library and you want to be able to add custom data to that struct so you can associate more data with it. If you dont do that then you would need a global hash map that uses the structure pointer as a key and your custom data as a value.
            Gtk for example uses void* for callback function and structs.

        • 1 week ago
          Anonymous

          >dynamically typed pointers
          naggerlicious language

          • 1 week ago
            Anonymous

            not really. that would mean it can determine the type pointed to automatically, which isn't the case. while any pointer can become a void pointer, the void pointer requires explicit cast to be converted (or reinterpret_cast in c++). if you know java, it's the equivalent of having an Object reference. has a few use cases, but 99% of the time you don't use it if you're not a retard.
            c still a naggerlicious language though

          • 1 week ago
            Anonymous

            No, you have to cast it to a type to actually do anything with it

  3. 1 week ago
    Anonymous

    >segmented far pointers

  4. 1 week ago
    Anonymous

    >use C# so don't have to learn about pointers
    >*null reference exception blocks your path*

    • 1 week ago
      Anonymous

      pointers are easy to learn when you think of character and string arrays

  5. 1 week ago
    Anonymous

    Why? What's your point?

    • 1 week ago
      Anonymous

      6 inches

  6. 1 week ago
    Anonymous

    If you ever get an actual job you'll quickly change your mind about them.

Your email address will not be published. Required fields are marked *