News for hackers. Stuff that matters.
Re:Ask HN: Good C++ code bases to read? by monocasa on Wednesday October 28, 2020 @03:57PM (#24923432)
The ideal situation is then to not use std::optional for those cases rather than to make std::optional next to useless for it's stated case.

If it gets in the way of your goal on an 8Mhz controller, take the optionality check out of your tight loop and convert to a null pointer safely where it doesn't matter.

Deeply embedded is already used to picking and choosing features, or explicitly running with the bumper rails off in the subset of cases where it matters. We like the normal primitives not being neutered for us because we still use a lot of them outside of our tight loops.

Re:Ask HN: Good C++ code bases to read? by CyberRabbi on Wednesday October 28, 2020 @04:36PM (#24923830)
> than to make std::optional next to useless for it's stated case.

This is such a ridiculous and obviously false assertion that it’s indistinguishable from satire. Optional is widely used and was modeled from a pre-existing boost class which was itself widely used. Do you actually write C++ professionally?

Re:Ask HN: Good C++ code bases to read? by monocasa on Wednesday October 28, 2020 @05:05PM (#24924137)
Yes.

And I think (hope?) that std::optional is going to make it's way into the dust bins of history like auto_ptr.

When the answer is "just don't deference it if it's null", then why not just use a pointer in the first place?

Re:Ask HN: Good C++ code bases to read? by CyberRabbi on Wednesday October 28, 2020 @10:28PM (#24926442)
Again, optional is different from pointer because it offers value semantics.
Re:Ask HN: Good C++ code bases to read? by monocasa on Wednesday October 28, 2020 @10:44PM (#24926550)
I know they're different (and the construct unfortunately named optional has some occasional uses); it's just that the semantics of optional don't help it be used as a classic optional type.
Re:Ask HN: Good C++ code bases to read? by jcelerier on Thursday October 29, 2020 @05:16AM (#24928582)
> it's just that the semantics of optional don't help it be used as a classic optional type.

what do you mean "classic optional type"? boost.optional has worked like that for something like 20 years - it's been in C++ for longer than Maybe has been in Haskell.

Re:Ask HN: Good C++ code bases to read? by tome on Thursday October 29, 2020 @01:32PM (#24932924)
> it's been in C++ for longer than Maybe has been in Haskell.

Tangentially, how did you conclude that? Haskell has around since 1990 but boost only since 1999, as far as I can tell.

https://en.wikipedia.org/wiki/Haskell_(programming_language)

https://en.wikipedia.org/wiki/Boost_(C%2B%2B_libraries)

Re:Ask HN: Good C++ code bases to read? by monocasa on Thursday October 29, 2020 @07:39AM (#24929410)
It's been in Standard ML since the 80s.