filter enhancements

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, LCMark

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1206
Joined: Thu Apr 11, 2013 11:27 am

Re: filter enhancements

Post by LCMark » Mon Jun 03, 2013 9:19 am

Lol.. Jan.. just do what I do. Pick one of:
- Implement it, send the pull request, do whatever runrevmark wants to make him happy with it then tell people it's done.
- Post here to discuss the idea, do whatever runrevmark wants to make him happy, implement it, send the pull request.
Lol - it's not about making me happy - it's about making sure the changes we make (as a whole) are as good as they can be. Designing syntax is not an easy task (particularly when it's English-like) and It's good to discuss these things so you don't end up missing something that could end up being more succinct.

I really don't really see these long discussions as 'bikeshedding' (although I did find the reference amusing) - as @mwieder points out once you decide on syntax its hard to change in the future (unless you want a lot of people complaining about their scripts breaking ;)). Also, by discussing the different ways of expressing things, we might end up finding other abstractions unrelated to this particular feature that would work elsewhere.

In any case, I like the last proposed syntax - it's consistent with the old-style format, and establishes the syntax [ {wildcard | regex} [ pattern ] ] as a new concept in the language - i.e. a string that is interpreted as a pattern. The latter aspect can be iterated to both 'replace' and to a 'matches' operator in time :)

As an aside: I do wonder how much discussion goes on in standardization committees about more established languages such as C/C++ - given the length of time between standards, I think we are doing quite well ;)

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Mon Jun 03, 2013 5:11 pm

@runrevmark
I think the reason we're doing quite well is that the language already has plenty of syntax examples to learn from and apply as guidelines.
Over the years LiveCode has vastly expanded on the original HyperTalk language, so there's more existing stuff to conform to.
We may be stuck with some of the more 'quirky' choices of the past, but luckily RunRev is a good custodian in case we get carried away ;-)

Open discussions are very good in this regard; I'll do my best to only use the term bikeshedding when truly applicable.
De gustibus et coloribus non disputandum est - but that doesn't mean we can't find a consensus on syntax, which I think we have reached in the end.

Now let's see if I understood the parsing mechanism correctly. No compile errors doesn't mean I got it right :-D

Cheers,

Jan.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: filter enhancements

Post by mwieder » Mon Jun 03, 2013 5:39 pm

No compile errors doesn't mean I got it right :-D
No, but it's a good start.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: filter enhancements

Post by mwieder » Mon Jun 03, 2013 5:46 pm

@runrevmark-
Lol - it's not about making me happy
Yes, but I know you're not happy until a proposed change is rock-solid and won't cause complications, so if we work at this until you're happy then we've accomplished our goal. I appreciate your conservative approach to make changes, where I'm more likely to just throw something out there and think about the consequenses later. That's why I think these discussions are good - we can all poke holes in each others' ideas until something solidifies.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Tue Jun 11, 2013 6:43 pm

Update
I've been working on this in a branch 'experiment-tinker_command' and been pushing the commits to github. GIven that my first (not so good) changes to the filter command brought the IDE to a grinding halt, I decided to first get it working correctly as a separate 'tinker' command and then shoe it back into the 'filter' command.

Currently at the stage where the following syntax works properly, including the 'convert' semantics:

Code: Select all

tinker [ { lines | items } of ] <container_or_expr> { with | without } <filter_pattern> [ into <target_container> ] 
Next up: introduce 'matching' as synonym for 'with' and 'not matching' as synonym for 'without'

Cheers,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: filter enhancements

Post by monte » Tue Jun 11, 2013 9:25 pm

Maybe tinker should be a synonym ;-)
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Thu Jun 13, 2013 10:58 pm

No, Monte - I would save 'tinker' for a much more important command in the future :-)
And to those interested in the progress: I just pushed regex support to my repository.
Some more testing (and probably fixing) needed and then I can implement and submit it properly.

Cheers,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Sun Jun 16, 2013 11:31 am

Update
Revised the implementation as I wasn't happy with the way it looked (OO code-smell). After another round of testing, started over from the 'develop' branch.
Everything seems to work as expected, so I submitted pull request #73.
If anyone's interested, take a look at the feature-filter-enhancements branch in my repository.
I will save 'filter items in lines of' for another time, preferably in one go with 'sort items in lines of'.

Cheers,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Tue Jul 02, 2013 5:08 am

Update
Pull request accepted (after some memory management improvements by @runrevmark) so this will be part of the next functional release (6.2?)
Thanks everyone for the feedback and advice - I quite enjoyed this project and look forward to tackling another one :-)

Cheers,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: filter enhancements

Post by monte » Tue Jul 02, 2013 5:47 am

Cool! Would love to see array key and element filtering too.
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

edgore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 197
Joined: Wed Jun 14, 2006 8:40 pm

Re: filter enhancements

Post by edgore » Thu Jul 11, 2013 5:11 pm

After reading through this thread I am still not sure if the proposed additions to filter would do something that I frequently have to implement in "for each" loops.

I work with a lot of data that consists of lines with multiple items and I want to, say, filter down to only the lines where item 3 contains a particular value. So, I want to filter by the value of item 3, but I want to keep the entire contents of the line, not just the contents of the matching item. I think I saw something in the thread that indicates that could be done, but I am not sure.
Last edited by edgore on Thu Jul 11, 2013 10:23 pm, edited 1 time in total.

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Re: filter enhancements

Post by Janschenkel » Thu Jul 11, 2013 8:04 pm

When I have the time, I'll see about implementing the filter-map-reduce triad that would allow you to filter the lines of a container by means of an expression that evaluates to true or false. But I have a long list of things to finish first.

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

DarScott
Posts: 227
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: filter enhancements

Post by DarScott » Sat Jul 13, 2013 2:41 pm

I come from a functional programming background and find the idea of map and reduce (and even filter) intriguing.

Maybe those can be part of a rich expression syntax.

We already have item and element polymorphism in some functions. This can be generalized for all expressions. This can even apply to destination chunks. This can even have readable logical reduction such as "all" and "some".

I do like the idea of even a simple filter based on a logical expression. That would have simplified a problem that came up on the use-LiveCode list.

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: filter enhancements

Post by mwieder » Sat Jul 13, 2013 6:59 pm

Until that came up on the use-list I didn't realize you could use boolean operators on filters operands.

DarScott
Posts: 227
Joined: Fri Jul 28, 2006 12:23 am
Location: Albuquerque
Contact:

Re: filter enhancements

Post by DarScott » Sat Jul 13, 2013 7:31 pm

I saw the boolean in filter but didn't believe it. Learn something every day.

Locked

Return to “Engine Contributors”