Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case macro using C++17 structured bindings. #76

Open
elfprince13 opened this issue Jun 13, 2017 · 3 comments
Open

Case macro using C++17 structured bindings. #76

elfprince13 opened this issue Jun 13, 2017 · 3 comments

Comments

@elfprince13
Copy link
Contributor

Discussion in #67 and https://github.com/solodon4/Mach7/blob/master/code/test/unit/example04-smart-ptr.cpp notes that binding a reference from a smart pointer is unwieldy due to poor language support for proxies.

It seems that being able to unpack directly into the target variables via structured bindings would make for a much cleaner solution.

Are there any major hurdles in the existing implementation to doing this?

@elfprince13
Copy link
Contributor Author

(and I guess this is off-topic from the issue title, but addresses the same problem of binding references)

Alternatively, an LCase, that looked something like this:
LCase(C<A>([](vars,bound,from,a){body}));
Instead of like:
Case(C<A> (vars,bound,from,a)) body;

@solodon4
Copy link
Owner

Regarding the 2nd note: there were other attempts at using lambdas for pattern matching of which I was aware at the time, but decided not to go that direction. Main reason - lambdas are still functions and you get control inversion with them. When I put return inside Case statement I would like to be returning from the function I'm in, not a callback used for syntactic purposes. I also saw performance numbers of those attempts at the time and it was a definite no go in comparison to the performance the current switch gives you.

Regarding structured bindings - yes, i'm planning to exploit them, just didn't have time to play around with options. Structured bindings were inspired by this library among other things :)

@solodon4
Copy link
Owner

solodon4 commented Jul 6, 2017

Forgot to mention in the previous post. If you don't particularly care about performance, you might want to look at Simple, Extensible C++ Pattern Matching Library - it uses lambdas for syntactic sugar and doesn't use any macros AFAIK. The author had presentation at CppCon 2015 I believe, you might want to check his talk for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants