Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. "Bill why do you hate optional<T&> so much?" Bill:

"Bill why do you hate optional<T&> so much?" Bill:

Scheduled Pinned Locked Moved Uncategorized
22 Posts 6 Posters 0 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

    @asperamanca -O3 is not “debug perf” ; inlining + Scalar Replacement of Aggregates can remove the runtime costs but not the debug perf, compiler throughput, and debug UX costs.

    asperamanca@mastodon.socialA This user is from outside of this forum
    asperamanca@mastodon.socialA This user is from outside of this forum
    asperamanca@mastodon.social
    wrote last edited by
    #10

    @malwareminigun Ah, I missed that detail.
    Well, that's a tradeoff to consider, of course.

    1 Reply Last reply
    0
    • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

      Everyone quick hide me from @thephd

      thephd@pony.socialT This user is from outside of this forum
      thephd@pony.socialT This user is from outside of this forum
      thephd@pony.social
      wrote last edited by
      #11

      @malwareminigun It's a good change!

      malwareminigun@infosec.exchangeM 1 Reply Last reply
      0
      • thephd@pony.socialT thephd@pony.social

        @malwareminigun It's a good change!

        malwareminigun@infosec.exchangeM This user is from outside of this forum
        malwareminigun@infosec.exchangeM This user is from outside of this forum
        malwareminigun@infosec.exchange
        wrote last edited by
        #12

        @thephd I'm surprised you would say that 😅

        thephd@pony.socialT 1 Reply Last reply
        1
        0
        • R relay@relay.infosec.exchange shared this topic
        • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

          @thephd I'm surprised you would say that 😅

          thephd@pony.socialT This user is from outside of this forum
          thephd@pony.socialT This user is from outside of this forum
          thephd@pony.social
          wrote last edited by
          #13

          @malwareminigun Optional references was never a dogma about replacing pointers. It was moreso a tool for generic improvements and code safety (at the cost of simplicity and debuggability). You can't trap every pointer dereference in C or C++, but you can absolutely trap optional failures; it was only ever meant to be an additional tool in the toolbox.

          Hopefully we can get variant<T&, ...> and expected<T&, ...> to play ball in the same way, so we just have a functional ecosystem where I can choose between "blow my leg off" (raw union, raw pointer, error-code-and-out-param) and "set me up nicely and keep it lean & clean" (optional/variant/expected references).

          malwareminigun@infosec.exchangeM sdowney@mastodon.socialS 3 Replies Last reply
          0
          • thephd@pony.socialT thephd@pony.social

            @malwareminigun Optional references was never a dogma about replacing pointers. It was moreso a tool for generic improvements and code safety (at the cost of simplicity and debuggability). You can't trap every pointer dereference in C or C++, but you can absolutely trap optional failures; it was only ever meant to be an additional tool in the toolbox.

            Hopefully we can get variant<T&, ...> and expected<T&, ...> to play ball in the same way, so we just have a functional ecosystem where I can choose between "blow my leg off" (raw union, raw pointer, error-code-and-out-param) and "set me up nicely and keep it lean & clean" (optional/variant/expected references).

            malwareminigun@infosec.exchangeM This user is from outside of this forum
            malwareminigun@infosec.exchangeM This user is from outside of this forum
            malwareminigun@infosec.exchange
            wrote last edited by
            #14

            @thephd Pretty sure a lot of the folks who wanted optional<T&> were dogmatic about replacing pointers 🙃. Of course with standardization rarely does everyone want something for the same reason.

            Kinda reminds me of what happened with string_view. Google wants it because they see 1% of fleet-wide CPU for Google being spent in strlen, so they want no brakes. Microsoft wants it because they're pushing GSL and want to shut down memory safety issues so they wanted it to bounds check.

            Not sure how I feel about variant and expected. (Note that variant models a discriminated union and the core language forbids reference members of unions https://eel.is/c++draft/class.union#general-4 )

            horenmar@mastodon.socialH sdowney@mastodon.socialS 2 Replies Last reply
            0
            • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

              @thephd Pretty sure a lot of the folks who wanted optional<T&> were dogmatic about replacing pointers 🙃. Of course with standardization rarely does everyone want something for the same reason.

              Kinda reminds me of what happened with string_view. Google wants it because they see 1% of fleet-wide CPU for Google being spent in strlen, so they want no brakes. Microsoft wants it because they're pushing GSL and want to shut down memory safety issues so they wanted it to bounds check.

              Not sure how I feel about variant and expected. (Note that variant models a discriminated union and the core language forbids reference members of unions https://eel.is/c++draft/class.union#general-4 )

              horenmar@mastodon.socialH This user is from outside of this forum
              horenmar@mastodon.socialH This user is from outside of this forum
              horenmar@mastodon.social
              wrote last edited by
              #15

              @malwareminigun @thephd IIRC google saw advantage from string_view over std::string const&.

              And it's not like they don't like their bounds check, they want to change the layout of std::vector in libc++ to be T* + 2x size_t, because it makes `size()` calls faster, and they do bounds checking on every `operator[]` call.

              malwareminigun@infosec.exchangeM 1 Reply Last reply
              0
              • horenmar@mastodon.socialH horenmar@mastodon.social

                @malwareminigun @thephd IIRC google saw advantage from string_view over std::string const&.

                And it's not like they don't like their bounds check, they want to change the layout of std::vector in libc++ to be T* + 2x size_t, because it makes `size()` calls faster, and they do bounds checking on every `operator[]` call.

                malwareminigun@infosec.exchangeM This user is from outside of this forum
                malwareminigun@infosec.exchangeM This user is from outside of this forum
                malwareminigun@infosec.exchange
                wrote last edited by
                #16

                @horenmar I mean I think that shows that Google isn’t a hive mind 🙂

                1 Reply Last reply
                1
                0
                • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

                  Everyone quick hide me from @thephd

                  sdowney@mastodon.socialS This user is from outside of this forum
                  sdowney@mastodon.socialS This user is from outside of this forum
                  sdowney@mastodon.social
                  wrote last edited by
                  #17

                  @malwareminigun @thephd
                  Technically my fault.
                  @thephd just conclusively demonstrated that all other answers for optional<T&> were even worse.

                  1 Reply Last reply
                  0
                  • thephd@pony.socialT thephd@pony.social

                    @malwareminigun Optional references was never a dogma about replacing pointers. It was moreso a tool for generic improvements and code safety (at the cost of simplicity and debuggability). You can't trap every pointer dereference in C or C++, but you can absolutely trap optional failures; it was only ever meant to be an additional tool in the toolbox.

                    Hopefully we can get variant<T&, ...> and expected<T&, ...> to play ball in the same way, so we just have a functional ecosystem where I can choose between "blow my leg off" (raw union, raw pointer, error-code-and-out-param) and "set me up nicely and keep it lean & clean" (optional/variant/expected references).

                    sdowney@mastodon.socialS This user is from outside of this forum
                    sdowney@mastodon.socialS This user is from outside of this forum
                    sdowney@mastodon.social
                    wrote last edited by
                    #18

                    @thephd @malwareminigun
                    And deref on optional<T&> has a _hardened_ precondition.

                    malwareminigun@infosec.exchangeM 1 Reply Last reply
                    0
                    • thephd@pony.socialT thephd@pony.social

                      @malwareminigun Optional references was never a dogma about replacing pointers. It was moreso a tool for generic improvements and code safety (at the cost of simplicity and debuggability). You can't trap every pointer dereference in C or C++, but you can absolutely trap optional failures; it was only ever meant to be an additional tool in the toolbox.

                      Hopefully we can get variant<T&, ...> and expected<T&, ...> to play ball in the same way, so we just have a functional ecosystem where I can choose between "blow my leg off" (raw union, raw pointer, error-code-and-out-param) and "set me up nicely and keep it lean & clean" (optional/variant/expected references).

                      sdowney@mastodon.socialS This user is from outside of this forum
                      sdowney@mastodon.socialS This user is from outside of this forum
                      sdowney@mastodon.social
                      wrote last edited by
                      #19

                      @thephd @malwareminigun
                      Placeholder for now:
                      https://github.com/bemanproject/expected

                      1 Reply Last reply
                      0
                      • sdowney@mastodon.socialS sdowney@mastodon.social

                        @thephd @malwareminigun
                        And deref on optional<T&> has a _hardened_ precondition.

                        malwareminigun@infosec.exchangeM This user is from outside of this forum
                        malwareminigun@infosec.exchangeM This user is from outside of this forum
                        malwareminigun@infosec.exchange
                        wrote last edited by
                        #20

                        @Sdowney Not sure how meaningful that is because nullptr* is checked by the operating system / hardware on every platform that matters. nullptr isn't a problem, only wild pointers 🙂

                        (Yes I know that isn't technically true for PMFs/PMDs always but those are not used too often)

                        1 Reply Last reply
                        0
                        • malwareminigun@infosec.exchangeM malwareminigun@infosec.exchange

                          @thephd Pretty sure a lot of the folks who wanted optional<T&> were dogmatic about replacing pointers 🙃. Of course with standardization rarely does everyone want something for the same reason.

                          Kinda reminds me of what happened with string_view. Google wants it because they see 1% of fleet-wide CPU for Google being spent in strlen, so they want no brakes. Microsoft wants it because they're pushing GSL and want to shut down memory safety issues so they wanted it to bounds check.

                          Not sure how I feel about variant and expected. (Note that variant models a discriminated union and the core language forbids reference members of unions https://eel.is/c++draft/class.union#general-4 )

                          sdowney@mastodon.socialS This user is from outside of this forum
                          sdowney@mastodon.socialS This user is from outside of this forum
                          sdowney@mastodon.social
                          wrote last edited by
                          #21

                          @malwareminigun @thephd

                          The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.

                          This works, really, but fails because tuple can hold a reference.

                          malwareminigun@infosec.exchangeM 1 Reply Last reply
                          0
                          • sdowney@mastodon.socialS sdowney@mastodon.social

                            @malwareminigun @thephd

                            The variant is the reference type for the iterator for the heterogeneous collection that is std::tuple.

                            This works, really, but fails because tuple can hold a reference.

                            malwareminigun@infosec.exchangeM This user is from outside of this forum
                            malwareminigun@infosec.exchangeM This user is from outside of this forum
                            malwareminigun@infosec.exchange
                            wrote last edited by
                            #22

                            @Sdowney I'm not sure how useful such an iterator is, particularly given that variant and tuple probably want different answers on the rebind vs. assign-through question. (tuple must be assign-through for std::tie/std::forward_as_tuple et al. to work. But @thephd showed us that variant probably wants rebind instead?)

                            I know it's encouraging to think of optional<T> as variant<monostate, T> but assignment is one place I can't mentally make them agree

                            1 Reply Last reply
                            1
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups