-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
extend get filter for data #1375
Conversation
for a data tiddler, returns the value at the index specified in the operand ``` <$list filter="[<dataTiddler>index<dataIndex>]"/> ``` do code-revision => first time user of the parser object
Thinking about it, maybe it should be called value instead? |
Or data to clearly indicate the connection with data tiddlers. The word index denotes the name (or key) of the name–value pair. (I don't much like the word index myself, because it's too overloaded and thus it risks confusing people.)
Actually, you don't need to use the parser object at all here. There are wrapper functions available, such as However, this new operator is so reminiscent of the existing
|
@aelocson, indeed. I very much like the idea of keeping the number of filters as small as possible, so using a suffix for get is indeed a much better approach. I'll do as you suggest, test, and actually change the code and ticket. |
now you can do `[all[current]get:data[foo]]`
@Jermolene ...btw. welcome back. :-) Although I am quite doubtful about the suggested performance increase, I went ahead and split the iterator in two, as suggested at the other filters. However, there are two things I'm wondering about with get:
|
Hi @tobibeer
If you're reading a bunch of values and you want to be able to refer to a specific one, then we need to have the full array. If identical entries in the array were merged then the indices would no longer match.
Intentionally we don't distinguish between a missing field and a blank field. The reason is that we don't have a value to use for missing fields. |
I think it would be more consistent with the other data index-related filter operators to introduce a new filter for this, and not reuse |
That is what I was trying to say: This is not what we get. We don't get the full array. We only get values for those where the field is defined and not empty, so the result-set does not match the source set as it is right now. If we return duplicates, should we not also return blanks?
What's wrong with
Would you perhaps prefer Currently, with text-references we are also fetching either fields or data. So, it seemed consistent to have the get filter do that as well, even though not making use of the text-reference syntax, surely. |
Ah, I see, yes, that does sound reasonable.
Using "" to indicate a missing field is fine, it just isn't distinguishable from a field with the empty string as its value.
Well, I'd prefer to use the word "index" so that it's grouped with the other index-related filters.
I agree, it was worth exploring. |
Not as a filter result, that's true. However, I would expect
Haha, that's what this pull request started out as. ^_^ Ok, so I will leave the get filter with its inconsistency untouched for now. Do you think that this index filter is indeed a worthy / needed addition for the core or would you, in fact, wait until someone asks for it? |
How about |
|
getIndex sounds good, bundling it with get, namewise, while also having a relation to index. Ok, so I revert to the initial request, change the name, add tests... and perhaps make a new pull request altogether, so that this thread remains as is for history's sake. Just realized, I never updated that demo ^^. |
Great thanks @tobibeer |
@Jermolene (& @aelocson) , some more questions... If the source list had multiple data tiddlers with the same index, what do you expect the output to be: unique or duplicate values? I tend to think unique, to create a set. What would we gain from a list with duplicates? Same with get. Whom are we helping with duplicates if most all entries in source may not have that field or that index? If we allow duplicates, should there be a "once" filter to remove the duplicates later? |
If there's a chance that any future operators may output duplicates, a |
Hmm I wonder if one underlying problem here isn't that |
Maybe |
Sounds sensible. Does that have the potential to break anything? |
The behaviour of |
I agree about
|
For a data tiddler, returns the value at the index specified in the operand
demo: http://tbdemo.tiddlyspot.com/#Index%20Filter