- Tricky! - 2 Updates
- Best C++20 feature - 2 Updates
- Tricky! - 3 Updates
- Question about ARM relaxed memory model.. - 3 Updates
ram@zedat.fu-berlin.de (Stefan Ram): Jul 29 04:10PM >I think she is inspired by (possibly someone else who is inspired by) an >article by the Go language creator. One context where one would like to return a variant with either a pointer to the active function or a sentinel value is a trampoline (which can be used to user-implement TCO in languages without it). |
ram@zedat.fu-berlin.de (Stefan Ram): Jul 29 08:13PM Supersedes: <trampoline-20190729170836@ram.dialup.fu-berlin.de> [PS] >I think she is inspired by (possibly someone else who is inspired by) an >article by the Go language creator. One context where one would like to return a variant with either a pointer to the active function or a sentinel value is a trampoline (which can be used to user-implement TCO in languages without it). PS: The above is not entirely correct. Actually, one wants to return a newly created function for trampolining. Sorry! |
Juha Nieminen <nospam@thanks.invalid>: Jul 29 02:25PM > Surely it would have been better to not introduce a new keyword, and > rather add another meaning for static. ;-) Well, they used 'class' for strong enums, so "typedef class"? |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 29 06:00PM +0200 On 29.07.2019 16:25, Juha Nieminen wrote: >> Surely it would have been better to not introduce a new keyword, and >> rather add another meaning for static. ;-) > Well, they used 'class' for strong enums, so "typedef class"? Sounds nice but that syntax already has a meaning. On the third hand, `auto` also already had a meaning. Cheers!, - Alf |
Bonita Montero <Bonita.Montero@gmail.com>: Jul 29 01:49PM +0200 I need a class-function / method that returns a function-pointer to the same type of class-function. How do I implement this? I need this to have a kind of state-machine where each state-func- tion returns a pointer to the next state function. I.e I would write: "while( (fn = state->*fn()) != nullptr );". I see no way to define the type of fn since it is recursive. |
"Öö Tiib" <ootiib@hot.ee>: Jul 29 06:30AM -0700 On Monday, 29 July 2019 14:49:58 UTC+3, Bonita Montero wrote: > tion returns a pointer to the next state function. I.e I would > write: "while( (fn = state->*fn()) != nullptr );". I see no way > to define the type of fn since it is recursive. Perhaps there are no way to make a function that return function pointer of its own type. However I do not understand the need of it. There is state and there is its handler and if you really need conversions between state and handler then you may make conversion constructors/operators ... but in my humble opinion it feels a bit messy and confusing. Here is example: #include <iostream> // state class State { public: using Handler = State (*)(int); State(Handler h) :handler_(h) { } operator Handler() {return handler_;} private: Handler handler_; }; // example handlers State DoSomethingA(int param); State DoSomethingB(int param); // example of usage int main() { State::Handler s(DoSomethingA(0)); s = s(1); s = s(2); s = s(3); s = s(4); } // implementations of handlers State DoSomethingA(int param) { std::cout << "A: " << param << '\n'; return DoSomethingB; } State DoSomethingB(int param) { std::cout << "B: " << param << '\n'; return DoSomethingA; } If it does miss what you asked for then post actual example code what are your handlers and what usage are you trying to achieve. |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Jul 29 05:59PM +0200 On 29.07.2019 15:30, Öö Tiib wrote: > Perhaps there are no way to make a function that return function > pointer of its own type. However I do not understand the need > of it. I think she is inspired by (possibly someone else who is inspired by) an article by the Go language creator. As I recall his examples work nicely in Go, or assembly language, or a more dynamic language like Python, but have to be rewritten with some indirection for a language with strong static type checking like C++. The reason for doing it that way, in languages where it's simple, is the textual simplicity of the source code. Since it doesn't give that textual simplicity in C++, it's not a good way in C++. It's doable, just not in any practical way. Cheers!, - Alf |
guinness.tony@gmail.com: Jul 29 01:16AM -0700 > But i need to understand if loads with older stores to the same location have total order in relaxed memory model of ARM CPU ? > And i need to know if stores to the same location have total order in relaxed memory model of ARM CPU ? > And i need to understand if stores with older loads to the same location have total order in relaxed memory model of ARM CPU ? RTFM. And stop spamming comp.programming.threads |
Juha Nieminen <nospam@thanks.invalid>: Jul 29 02:26PM >> And i need to understand if stores with older loads to the same location have total order in relaxed memory model of ARM CPU ? > RTFM. > And stop spamming comp.programming.threads I would not classify asking on-topic questions as "spamming". |
Bonita Montero <Bonita.Montero@gmail.com>: Jul 29 04:32PM +0200 >> And stop spamming comp.programming.threads > I would not classify asking on-topic questions as "spamming". Posting a lot of redundant stuff which no one would read because there s nothing new in it is spamming. And there is a substantial part of his postings which is not related to threading. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment