-
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
[IDEA] :sort prefix and extensible filter run prefixes #5166
Comments
Not only that, there's also I strongly dislike the idea of having suffixes for filter run prefixes ( |
@rmunn the feeling is mutual about suffixes for filter runs and comprehension. The sort options I listed are the ones supported by the As for the utility of the sort prefix, I find filters written inline far easier to read, comprehend and maintain.
Yes that is the issue and that is why this is an issue for discussion rather than a PR. I realize this might not be appropriate for the core and am happy writing this as a plugin for myself. The key advantage gained with the refactoring to support the filterrunprefix modules is that plugins can now add filter run prefixes. However before I started writing code, I wanted to talk this out and see if there was a third alternative I was missing as neither proposed solution is entirely satisfactory. |
So are you going to end up creating a prefix version of every filter that takes a subfilter argument, like As for a third alternative, I'm not seeing one. I think you'll just have to implement a separate filter prefix for every possible variant, finding appropriate names. (Though implementation can just have one implementing function and all the others are simple wrappers around it.) A |
@rmunn unless I can think of a better implementation, this will likely be a plugin for personal use and as such I would only write the prefixes that I find myself needing. With the way that I use TW that is pretty easy to plan in advance. As you say the sheer number of prefixes required would make this a non-starter as a public plugin. Part of the reason I wanted to bring this up now before 5.1.23 went live was in case I had missed a trick with the filter run prefix implementation, and maybe someone else might spot a more flexible and elegant solution. |
I like the idea of making things like "reduce" available in inline form. Having a profusion of filter prefixes doesn't feel bad because we can already be confident that the vast majority of users need never learn about their existence. |
@Jermolene I'll do some prototyping post 5.1.23 and we can then discuss the merits while looking at some code. |
After thinking about this some more while writing #5246, I've come to the conclusion that filter run prefix suffixes, as ugly as that phrase is to type, might actually be necessary due to the fact that |
Notwithstanding my earlier comment, I agree that adding filter run prefix suffixes makes a lot of sense. With reference to the clumsy nomenclature, perhaps this is our last chance to rename "filterrunprefix" to avoid the overloading of the term "prefix". We might use:
Maybe the word "run" is redundant so we could have:
|
@Jermolene I would suggest I don't think we should drop the word "run" as I could potentially see |
That's rather my concern with "type": that it's too generic a term, and already littered through our code.
Very good point. Also to add:
|
Do note that we do already use the term filter run prefix in docs for some time, but a change might be warranted here to avoid more confusion down the road. |
Tsk I had forgotten, and thought we'd introduced the term with v5.1.23. I think the naming boat has sailed then, we'll have to live with it. |
Now that we have support for suffixes for filter runs, I'll revisit the idea of a I am considering the following syntax upon which I welcome input:
Where
It is a bit tricky trying to have consistency with the
Thoughts? As a reminder, the use case for this is to allow filters like:
instead of:
|
Thanks @saqimtiaz that seems sound to me. |
@Jermolene an issue regarding case sensitivity and consistency.
So how should the prefix My original intention was to have Alternative proposal is to use a suffix switch for case sensitivity which means it can be applied to
Without the Edit: please do consider the matter of consistency with |
I do like I think: |
Thanks @saqimtiaz @pmario I do like the idea of pulling the case sensitivity flag into its own suffix; "stringcs" et al always feels like a bit of a hack. |
@Jermolene what should be the default for However note that |
I think we may be stuck with having inconsistent defaults, so we should perhaps encourage the convention of always explicitly specifying the case sensitivity flag? |
I think the default for the |
Just as the
:filter
filter run prefix provides an inline alternative to thefilter
operator, it would be desirable to have a:sort
filter run prefix where the list is sorted by comparing the results of applying the filter run to each list item. This would be an inline alternative to thesortsub
operator.[tag[HelloThere]] :sort[get[text]length[]]
instead of:
However, we currently support multiple types of sorting:
string
,integer
,number
,date
andversion
So either we would need to add 5 filter run prefixes, one for each of the sort types.
:sortstring
,:sortinteger
etc...Or we could consider supporting suffixes for filter runs. Example :
[tag[HelloThere]] :sort:string[........]
or[tag[HelloThere]] :sort:number[........]
While this second approach is a lot more flexible and powerful, the syntax might prove not so intuitive for new users.
Is there a third alternative that I am not thinking of?
I am interested in implementing this - even if only as a plugin - so I would appreciate any feedback or ideas.
The text was updated successfully, but these errors were encountered: