--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CANh-dXnGgkvmuzTv9tCsFtRfccJa-TT9vWYQrOBP8aTkcPpYxw%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAJL3UpRbtjwinuvsPZSsQH1wgWTR7i_vp_szYbM67dm8v2tuXQ%40mail.gmail.com.
So here's actual code that compiles. I could also port the Source/core/layout/ng/ng_block_flow_layout_algorithm.cc to this if that would be helpful. But here's an example:Note that if you do something that would skip the initialization, you get a compile error, so it is not such a subtle error.Also, I don't think it's fair to summarize the Google style guide as disallowing coroutines. It contains a blanket prohibition against most boost modules, but not a specific one against coroutines.
So here's actual code that compiles. I could also port the Source/core/layout/ng/ng_block_flow_layout_algorithm.cc to this if that would be helpful. But here's an example:
Note that if you do something that would skip the initialization, you get a compile error, so it is not such a subtle error.
Also, I don't think it's fair to summarize the Google style guide as disallowing coroutines. It contains a blanket prohibition against most boost modules, but not a specific one against coroutines.
On Tue, Aug 16, 2016 at 8:38 PM, Christian Biesinger <cbies...@chromium.org> wrote:So here's actual code that compiles. I could also port the Source/core/layout/ng/ng_block_flow_layout_algorithm.cc to this if that would be helpful. But here's an example:This code doesn't compile for me; at the very least everything inside <> seems to have been stripped.Note that if you do something that would skip the initialization, you get a compile error, so it is not such a subtle error.Ah, good that our compilers do catch it if you skip initialization, though of course if you skip a non-initializing declaration g++ won't complain, and clang++ requires only catches it due to -Wsometimes-uninitialized -Werror (which I think is covered by our flags). And the compiler will warn before you skip a non-trivial destructor. That does make me feel somewhat better.
https://gist.github.com/jeremyroman/7152901a577722c1331934b0d535d709Of course, if you do lift the local variable and initialize it outside of the "reenter", you get no warnings whatsoever. Similarly if you use any of the parameter variables.
Also, I don't think it's fair to summarize the Google style guide as disallowing coroutines. It contains a blanket prohibition against most boost modules, but not a specific one against coroutines.My reading of the rules in the style guide and the internal go/whynotboost suggests that it would be disallowed if proposed; it's a very new pattern that makes code using it harder to correctly understand for someone unfamiliar with the library in question (I've now spent a few hours understanding it, and only now do I think I might be able to write correct code with it), and you have to write code in a very particular way to be correct (even if the compiler will warn about some of the worse ones). I'm worried about the amount of time an average Chromium engineer would have to spend getting to grips with.Additionally, you've even run into a subtle bug in the example you provided, albeit ones that full warnings would have caught. You used the "statement" form of yield, which does not return a value. Instead, all of your yields actually return true, because by failing to use "yield return", you just transferred control to the end of the reenter block (where your other return statement executes). You intended to write "ASIO_CORO_YIELD return false;", which actually sets the result of the coroutine invocation.And the warning you get even with all warnings on is this (with clang):error: expression result unused [-Werror,-Wunused-value]ASIO_CORO_YIELD false;^~~~~
I feel like you have a very specific need and want to do layout in a very specific way. You've discovered that coroutines are a good way to express that. But to accomplish this goal I suspect it's not required that we add macro magic to support this very general paradigm, nor is it even required that we add general non-macro support for coroutine-style programming to our codebase (that you pointed out in an internal thread also exists).I think the best thing for you to do is figure out the exact minimal thing you need and spend some time massaging some classes to express the exact minimal think you want very clearly. You have chunks of layout work, I think you can make something with clear names, that programmers can step into in a debugger, and that this specific pattern can be documented so people can understand it when they see it. A surgically-specific approach to how you want layout to work will be much easier to explain and maintain for our large team over a long period of time than the overly general and not-easily-explained concept of coroutines.
Jeffrey
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CANh-dXkSJN3k_-hSE-CbXtTL17y3mwsXymssEGzkGmnofAdgNw%40mail.gmail.com.
On Wed, Aug 17, 2016 at 1:22 PM, Jeffrey Yasskin <jyas...@chromium.org> wrote:On Tue, Aug 16, 2016 at 10:09 PM, Brett Wilson <bre...@chromium.org> wrote:I feel like you have a very specific need and want to do layout in a very specific way. You've discovered that coroutines are a good way to express that. But to accomplish this goal I suspect it's not required that we add macro magic to support this very general paradigm, nor is it even required that we add general non-macro support for coroutine-style programming to our codebase (that you pointed out in an internal thread also exists).I think the best thing for you to do is figure out the exact minimal thing you need and spend some time massaging some classes to express the exact minimal think you want very clearly. You have chunks of layout work, I think you can make something with clear names, that programmers can step into in a debugger, and that this specific pattern can be documented so people can understand it when they see it. A surgically-specific approach to how you want layout to work will be much easier to explain and maintain for our large team over a long period of time than the overly general and not-easily-explained concept of coroutines.This strikes me as similar to saying that Javascript doesn't need async/await, that callbacks are just fine. I don't think that's a common position for Javascript, and it shouldn't be a common position for C++.Well, javascript is a different language, it's hard to compare. C++ doesn't have garbage collection or weak typing either.I think I see value in coroutines if they're a first class citizen in the language, supported by the compiler and tools (debugger, etc.). I have more doubts if they are implemented using macro goop - one more DSL to learn :(
In light of the opposition to the proposal, I want to withdraw it. We will go ahead with a regular state machine and see how that works out for us.