valueDiff for arrays?

Mark Waddingham mark at livecode.com
Sun Aug 5 18:03:18 EDT 2018


On 2018-08-05 23:48, Monte Goulding via use-livecode wrote:
>> On 6 Aug 2018, at 7:07 am, Mark Waddingham via use-livecode 
>> <use-livecode at lists.runrev.com> wrote:
>> 
>> filter X by keeping the lines not matching pattern "regex"
> 
> My point was this statement can be written as both:
> 
> filter X by keeping the lines not matching pattern “regex"
> 
> and
> 
> filter X by discarding the lines matching pattern "regex"
> 
> So it would perhaps be a good idea to only allow `matching` rather
> than `not matching`

To be fair - we could get rid of the inverted forms entirely. If you 
want inclusion, use keep, if you want exclusion use discard. i.e.

   filter X by keeping the lines with "..."
   filter X by keeping the lines matching "..."
   filter X by keeping the lines where "..."

   filter X by discarding the lines with ".."
   filter X by discarding the lines matching ".."
   filter X by discarding the lines where ".."

This would probably work much more nicely actually (now I get what you 
were saying!) - it means you don't have the 'double-negative' problem 
(which I think is what you were referring to) - and 'where' gives you a 
general 'get out' especially if we implement the 'matches' operator:

   filter X by discarding the lines where each does not match "..."

So no expressivity is lost - but you retain the absolute clarity of 
having keep/discard.

At the end of the day - why would you choose to use an extra token for a 
negated form, when you can just change keeping to discarding - or vice 
versa?

> Hehe.. the `with expression` thing was me trying to come up with
> something that worked with `with | without | matching | not matching`…
> `where` is much better I agree.

Hehe - yeah - I think we've discussed it before (probably several times 
over a long interval) so that at least require's no bike-shedding... 
After all, in this case, if its good enough for SQL, I can't see why it 
isn't good enough for us (it also happens to be entirely correct from an 
English language point of view - which kinda helps, in an English-like 
language).

Warmest Regards,

Mark.

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list