6 ms·
well the (;) is the `bind. The problem with the question is that it only works on a conceptual level as C++ does not have type system support for statements. (
by toolslive 9y ago
well the (;) is the `bind.
The problem with the question is that it only works on a conceptual level as C++ does not have type system support for statements. (ie, in {a;b} what's the type of a ?)
But, it allows them to see how you could build fiber/promises/lightweight_threads support using this concept, which is most of the times what they are interested in anyway.
- dllthomas 9y agoIt could pass statements as functions. Imagine a syntactic transformation from `a; b` to `[&](){a;} >> [&](){b;}` (though of course there are lots of details left unspecified...)
- nickpsecurity 9y agoI never thought about shifting perspective on the semicolon from imperative to function. I'll have to revisit the idea after I learn functional programming. For now, maybe what you describe could be possible with tools that do C++ metaprogramming in Haskell or Racket like below. I liked what I was reading despite not even using those languages. ;) http://aszt.inf.elte.hu/~gsd/s/cikkek/abel/haskelltmp.pdf http://aszt.inf.elte.hu/~gsd/s/cikkek/abel/haskelltmp.pdf http://matt.might.net/papers/ballantyne2014metameta.pdf http://matt.might.net/papers/ballantyne2014metameta.pdf
- marcosdumay 9y ago> ie, in {a;b} what's the type of a ? Well, C++ is entirely run on IO, so `a :: IO a`. It's exactly the first argument of Haskell's `(>>)` when specialized into IO.