« first day (3947 days earlier)      last day (1006 days later) » 

nwp
9:52 AM
I thought Java's mandatory exception decorations were regarded as a design error because it constantly leaks implementation details.
 
I don't like checked exceptions at all
 
nwp
I like being able to write exception-agnostic functions.
 
I feel like the couple of use-cases where you would think that checked exceptions are a plus you can get the same "advantages" with a result type and a lambda
 
 
2 hours later…
12:05 PM
Today I have learned there is such thing as the cat privacy screen, apparently cats need privacy when does own business too.
 
nwp
Privacy in front of a camera.
 
12:19 PM
That cat looked pretty pissed off, heheh.
 
1:05 PM
@Mikhail not in the sense of checked exceptions, but in the objective-c/swift/Herb's proposal
we need a better way of expressing failable functions without the overhead of exceptions and the likelihood of being ignored of return codes
 
yeah, the error handling facilities in the language/standard library are very much lacking at the moment
 
Honestly for rarely failing things, exceptions are fine. For extremely rarely failing things noexcept is fine. For things that are likely to fail and need to be handled by the direct caller they are not fine
 
1:32 PM
tfw you're using lambdas just so you can use std::make_integer_sequence to avoid a loop since it's always a fixed count
 
nwp
@Mgetz Isn't that fixed by [[nodiscard]]?
 
No because that can be ignored.
it also has issues with codesearchability
 
nwp
What do you mean that can be ignored? That programmers can choose to not mark their critical return codes with [[nodiscard]]?
 
no in the sense that I can just turn off the compiler diagnostic for it
there is nothing that will break if I just cast the return to void
whereas in herb's proposal and in swift you MUST handle it
you can't just cast it away
 
nwp
Unless someone adds a compiler flag that allows casting it away and you're back where you started.
I think if someone chooses to ignore [[nodiscard]] they lost their right to complain that they overlooked a critically important return value.
 
1:38 PM
@nwp except there are times when that's completely inappropriate. So making the API such that they must deal with it actually makes sense
apologies for the multiple ping replies
 
nwp
I think the code example is perfectly fine. The programmer explicitly dismissed the return value.
You will always need to do that anyways.
 
I feel like I'm failing miserably communicating this
there is value in calling out in the code "HEY THIS CAN FAIL"
 
nwp
Yeah. And square did exactly that. And the programmer answered "I DON'T CARE!". Which is fair.
Adding an option to express "I WILL MAKE YOU CARE!" will not turn out well.
 
headdesks
in cases where it needs to be handled I think it's valid to do so
even if the caller just says "I don't care"
it makes it much easier for someone following later to understand the intent
casting to void doesn't do that
 
nwp
You can't make people care. If you disallow (void) they will replace it with if (dontcare()) {} which then counts as handled. Or whatever the minimum code required is to express "I totally handled it, but don't care".
 
1:43 PM
I'm not saying disallow casting to void
I'm saying having a specific syntax in some cases
you do realize you're arguing in favor of basically allowing people to write really bad code?
 
nwp
Would requiring [[dismiss_nodiscard]] instead of (void) be a fix?
 
no because it doesn't express intent
having a try like syntax expresses intent
it says both that the callee can fail
and that the caller is deliberately not doing anything
 
nwp
So replace [[dismiss_nodiscard]] with [[on_fail]]?
 
it also doesn't compromise any return value that it may return normally
thus allowing a more ideal API
 
nwp
People will write really bad code no matter what you do. The best we can do is to give them sane defaults and to make bad code much more difficult to write than sane code. I would argue we reached that in this case. square(n); is the sane default and it doesn't compile. (void)square(n); is the weird bad code that sticks out in a code review.
 
1:48 PM
that doesn't mean we have to make it easier to write bad code
I'm thinking more like access or FS stuff not that
stuff that is extremely likely to fail and the caller is almost certainly likely to need to deal with it
 
nwp
Hmm. I understand your desire to be able to express that a function can fail and that failure must be accounted for, but on the other hand often you cannot handle the error anyway, you must pass it up the call stack. And exceptions are really good for that.
 
yeah this isn't for that in most cases
because the upstream caller isn't going to go "Oh well that folder doesn't exist I should create it"
 
nwp
I would also argue that "I couldn't read/parse the file" is worth an exception even if that happens very often.
 
they are going to "WTF is this crap"
read parse probably
open is meh
open can fail many different ways
 
nwp
Sure, but it doesn't matter what way it failed, you can't handle any of the cases.
 
1:53 PM
yes you can, if open failed you can swap to defaults
or create a new version
having a file fail to open is fairly common
 
nwp
Arguably that's for upstairs to decide. No reason to pass a chain of return codes that must be handled up the call stack.
 
why would an upstream function care about a file failing to open in most cases? It just wants whatever it was asking for
separation of concerns
 
nwp
The same argument applies to why a parsing function should care about what the default values are. Those, too, should be separate. And the parsing function is the one that encounters the IO error.
 
 
5 hours later…
6:40 PM
I just had the most brilliant idea ever
iterator_to_smart_pointer foo_it;
(*foo_it)->do_something();
but now
foo_it-->do_something()
 
decrement, bigger than do_something()? That's forbidden magic!
 
:-(
maybe
foo_it->>do_something()
 
6:55 PM
FYI operator->() supports chaining on class types.
> An expression x->m is interpreted as (x.operator->())->m for a class object x of type T if T::operator-> exists and if the operator is selected at the best match function by the overload resolution mechanism (13.3).
The operator is applied to every returned object until the returned type is a pointer.
 

« first day (3947 days earlier)      last day (1006 days later) »