valueDiff for arrays?

Mark Waddingham mark at livecode.com
Sun Aug 5 08:32:00 EDT 2018


On 2018-08-05 07:31, Monte Goulding via use-livecode wrote:
> Given I have been wanting to do ^ for a couple of years I decided to
> just go ahead and do it… might be a while before we have time to
> bikeshed the syntax though.
> 
> https://github.com/livecode/livecode/pull/6626
> <https://github.com/livecode/livecode/pull/6626>
> 
> Examples:
> local tFoo,tBar
> put "foo" into tFoo[1]
> put "bar" into tFoo[2]
> put "baz" into tBar[1]
> put "bar" into tBar[2]
> filter keys of tFoo with expression tFoo[each] is tBar[each]
> — tFoo now has one key 2 which is `bar`
> 
> put “yes,foo” & return & “no,bar” into tFoo
> filter lines of tFoo with expression item 1 of each is “yes”
> 
> We could feasibly not use `with|without` for this forcing the
> expression to return true to filter. If we went that way then perhaps
> `where` would be nicest?
> 
> filter lines of tFoo where item 1 of each is “yes”

Geez @Monte - you do like creating work for me don't you! ;)

In terms of syntax - definitely not 'with expression' - that's ghastly. 
It is a 'where' clause - in the same vein as SQL and other query 
languages - so no bike-shedding required there (also, pleasingly, all 
other 'filter' types become sugar for a where clause using operators 
which the language does not have yet - but obviously we have the code 
for...).

If we are going to bike-shed over syntax - can we do so over the use of 
'filter' itself. I don't know why but I have a complete mental block 
about it - regardless of how many times I use it or read it - I always 
have to 'double-think' to work out what form to use - is that just me?

   filter <things> of X with Y
   filter <things> of X without Y

I couldn't tell you just by looking *what* they actually do. I'm not 
sure why but I think the verb is actually wrong - in all cases you have 
a set of things and you are either keeping an element, or removing an 
element... So I wonder if:

   keep <things> of X where Y
   discard <things> of X where Y

(I'm not particularly attached to keep/discard - but it does need to be 
a pair of 'true' antonyms which don't intersect with any other 'core' 
pairs of such things we have).

Might be more appropriate?

Of course, maybe it is just 'with' / 'without' are inappropriate, and 
'where' might actually help me retrain my mind to see with/without as 
the sugar they truly are.

Anyway, thought it worth throwing out there to see what people think?

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