On 2018-08-05 22:37, Monte Goulding via use-livecode wrote:
I think it’s nice sugar but it adds complexity when trying to
understand the statement. You need to comprehend the expression or
pattern then comprehend the relationship between discarding/keeping
and with | without | not matching | where in order to figure out what
will actually happen. I would rather [by { keeping | discarding }] be
a parser error if used with without and not matching.

I'm not sure I follow - I think you took the above out of context - I was using an elided form of the operations to indicate the mapping from existence / non-existence of keywords to the underlying operation...

The form is actually:

  filter X by keeping the lines where P
  filter X by discarding the lines matching "glob"
  filter X by keeping the lines not matching pattern "regex"

* Yes I've inserted 'the' there - because it then makes the query expressions the same as Mark Wieder's suggestion. Also I might not have matching quite right - it might be a bit more verbose than that.

I'm not too fussed about whether the new form has with or without - they are the 'arcane' words in this situation which caused me the problem in the first place.

By arcane here I mean you actually have to read the docs to understand what they are referring to:

  filter X with "foobar"

Isn't exactly clear at first sight - "foobar" is a string - with <String> ? What does that mean? (You have to forget that you know *what* that command actually means to actually get my point - the reason I can do that easily is that I never remember correctly and always have to either try both or look it up).

I think the key point is that - out of context - which is generally the first phase of reading code:

  filter lines of X matching Y
  filter lines of X not matching Y

Makes no reference to what the 'default' mode of filter is - i.e. whether it keeps the solids, or keeps the liquids as Jacque put it. Given any recipe (to use the culinary metaphor) which in either case is entirely defined by *what* you are cooking (after all - how many recipes keep the fluid you get after draining potatoes, rather than the potatoes?)... But this isn't cooking - this is coding, so in this case you need to read the docs to find out what the default mode of filter is. (Of course, this might entirely be one of those things that my brain just won't get, or ever get - so it might very well just be me!).

If we insert an explicit keep / discard then it makes it crystal clear and unambiguous regardless of context.

Sure we can make the extra bits optional - so you can type less if you want - that's personal taste, and how much you want to torture yourself later, and others, when they read the code!

Anyway - extending the current form with 'where' (rather than 'with expression') is more than adequate at the moment.

The proposal above needs more work anyway - so it isn't an immediate thing in any case.

Warmest Regards,

Mark.

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

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to