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

variant_nested: easy dispatch chaining #1

Open
Llammissar opened this issue Jun 25, 2013 · 1 comment
Open

variant_nested: easy dispatch chaining #1

Llammissar opened this issue Jun 25, 2013 · 1 comment

Comments

@Llammissar
Copy link

I noticed the comment:
//TODO:support a.foo for a["foo"]?

Yes. But if possible I would seriously love for it to get taken a step further and work work with multiple levels. That is:

TomlNode root;
root.a.b.c = 42;
writeln(root.a.b.c); //Should print 42

I've actually been trying to get this very thing implemented off and on for weeks now, and the above snippet has been very elusive. From what I've found, getting it working one level deep is pretty easy; it's when you start trying to push it deeper that it sort of falls apart.

As of right now, I have two implementations: one with simple access but awful construction; one with simple construction but requiring an extra retrieval function at the end of the chain. (e.g.

root.a.b.c = 42;
writeln(root.a.b.c.val); //Prints 42

I'm pretty close to settling for the latter, but before that I'm going to try a few things with the code you have here-- if you have any thoughts on this, I'd love to hear them.

(Semi-related: what's the license for this repo?)

@timotheecour
Copy link
Owner

Ok, slowly getting back to it... sorry for delay.
For now:

one with simple construction but requiring an extra retrieval function at the end of the chain.

instead of val at the end, what about opCall, as I did here: https://github.com/timotheecour/dtools/blob/master/dtools/util/functional.d#L128

(Semi-related: what's the license for this repo?)

standard Apache V2

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