-
Notifications
You must be signed in to change notification settings - Fork 6
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
Lazy default children #25
Comments
This is wholly up how the data just is right? Or does FileTrees API somehow exacerbate it? # Ok, it is impossible to know whether c will match or not before exec
julia> reducevalues(+, ftd[r"(a|b|c)"]) |> exec
3
# So one has to remember to do this
julia> reducevalues(+, ftd[r"(a|b|c)"] |> exec)
6
I agree this is bad! I'm still working through all the content in this issue haha! Thanks a lot. We should probably open smaller issues for each item we can improve. |
Sorry for dumping a wall of text in the tracker. I hope it wasn't too painful to read :)
I would say it is a characteristic of the first naive defaultchildren implementation which assumes only the first given children will be created. It was just meant as a motivation for why that hacky FixMeUp struct was there in the second part. FileTrees API does not do anything to make it worse. In case it was unclear: I'm perfectly happy to have this as a one-off solution in my code. It may very well be one of those things where it is easier for people to create their own solution than it is for them to understand how to use a generic one. Having unkown children in the tree is most likely gonna end up clashing with lazyness in a lot of ugly ways. |
About my story from the discourse thread, I was a bit bored so I cooked up a solution which seems to work for my use case.
I don't know if this is clean and robust enough to be worthwhile to add, but here it is in case anyone finds it useful.
To summarize the use-case: Sometimes files contain multiple items which are useful to view as separate
File
s in the filetree in a way where it is not possible to know exactly which items they contain. One example of this are text logs where each line is printed out from some part of a program and different parts print different things, something like this:One might want to see this as
It is often known roughly what could be in there, so it makes some sense to have default children. Here I use a dict which maps child names to their values for easier groking, but this should be possible to abstract to a generic function. It is also hardwired to assume laziness for the sake of brevity.
Here is an example:
So far so good, but the big drawback is that if there are values produced by the creation operation which we have not guessed are there, they will never be seen:
Another issue is that one might not want to have the default children, only the ones which actually materialized.
Both of these are adressed by the following extension:
Now what happens? Check it out:
The text was updated successfully, but these errors were encountered: