3 ms·
>I don't know a way of doing that in any of the C style languages http://www.boost.org/doc/libs/1_49_0/libs/optional/doc/html/index.html http://www.boost.org/d
by GregBuchholz 11y ago
>I don't know a way of doing that in any of the C style languages
http://www.boost.org/doc/libs/1_49_0/libs/optional/doc/html/index.html http://www.boost.org/doc/libs/1_49_0/libs/optional/doc/html/...
https://www.google.com/#q=maybe+in+c%2B%2B https://www.google.com/#q=maybe+in+c%2B%2B
...and also I couldn't resist...
char* response(messy* message) {
body* b = message->body;
return b && (b->text) && b->linecount < 11 && b->text[10];
}
...for a C-ish like language. And that's without creating a "do-notation" macro to erase the &&, as the Haskell do-notation erases the >>=.
- evincarofautumn 11y agoThese aren’t quite the same. With “x && x->y”, you’re using a boolean to encode the assumption that “x” is valid, but with “x >>= getY”, the type system has a proof, which makes refactoring safer.