Replies: 7 comments 11 replies
-
Ilya, To sum-up. deep_set() will autovivify and set the provided value at path. To have a read/check access with autovivification you're ok to add a new function whose name is left to be agreed upon. You proposed
I would suggest
Where path is made of a sequence of at least one of
What do you think ? |
Beta Was this translation helpful? Give feedback.
-
Ok, deal :) if that's what it takes to have an autovivification API in NGS. 👍 |
Beta Was this translation helpful? Give feedback.
-
Reminder, mostly to myself: open issue - handle index type mismatch: using |
Beta Was this translation helpful? Give feedback.
-
Hi Ilya, I just thought about something. In my day work I rarely use JSON files. I can see some of them being use as inputs with some of the tools I use. I noticed, please correct me if I am wrong, but what Which means, unless I am wrong, there seem to be a 1-to-1 correspondance between a JSON file and what's get created using Am I wrong ? -Richard |
Beta Was this translation helpful? Give feedback.
-
One other remark. If we stick on solely using These deep Hash-only based data structures may be considered as a generalization of a normal single level Hash. Then it becomes interesting to create a new function call, say,
A lot of useful use cases, scenarios could be derived from that. Also we may go even one level further and replace the condition that triggers the invocation of our 1st closure, say, closure1, by another closure, closure2, that would take the current path of the level we are at as one argument and the corresponding value (Int, Arr, Hash, Any) as its 2nd argument. If the returned value of closure2 is true, Anyway, whether or not we use the fact that the current value during the parkour is not a Hash or use a closure for the condition, closure or closure1 respectively, would get called with both the path and its associated value. I think what you talked earlier about
could be useful with the So I think there is something interesting here to apply Like
What do you think ? |
Beta Was this translation helpful? Give feedback.
-
The idea of having a specific behaviour for a deep data structure solely based on Hash as intermediate nodes is that it simplifies the condition to call the Again, I see a Hash-based deep data structure as a generalisation of the 1-level Hash built-in objects. The idea is to be able to walk the Hash-based deep data structure and trigger calls to the closure without being forced to provide any explicit call condition. The default condition allowing
Whenever that default condition is met for a particular node then There is really nothing more to it. There was a time when this specific use case was pivotal to the tools I wrote in Perl5. Again, no matter how you want or plan to implement the walk into these deep data structures, it would help to have a default condition based on which to call the attached closure. What I mean but default condition is a condition that doesn't need to be explicitly mentioned during the call to |
Beta Was this translation helpful? Give feedback.
-
Let's discuss possible implementation - https://gist.github.com/ilyash-b/909461aee302de7f3286d1470863119f |
Beta Was this translation helpful? Give feedback.
-
In previous episodes:
Beta Was this translation helpful? Give feedback.
All reactions