Mark Waddingham mark at livecode.com
Thu Oct 29 13:50:14 EDT 2015

On 2015-10-29 16:47, Richard Gaskin wrote:
> Given how handy chunk expressions are in LiveCode, I'm wondering if it
> might be even handier to see the introduction of a new function,
> something that could perhaps be called "lineAtOffset".

Okay so:

    lineAtOffset(x, y, z)

Would be the same as:

    line lineOffset(x, y, z) of y

Presumably with the rule that if x is not in the lines of y, the return 
value is empty.

> Questions for you folks:
> 1. Is this as useful as I think it might be?

It certainly cuts down a few chars to type... In theory you only have to 
scan the string once up until the first delimiter after the needle 
string - so it would be more efficient (with a suitable implementation).

> 2. Is there a better name for the function?

Yes - I think there probably is. I'm not sure lineAtOffset() actually 
reads quite as well as it could for this purpose.

> 3. Would consistency with wordOffset, trueWordOffiset, and itemOffset
> bog this down to the point where we'd either have to face an
> make two calls.  But as I've noted before, sometimes I'm too easily
> satisfied and others may have more demanding requirements.

Consistency and completeness are important here. If we are going to 
introduce a function for one chunk type, then chances are someone will 
ask very quickly for one for another similar chunk type. So, it is 
always important to plan to make sure that it makes sense for 'all 
similar things'.

> 3. Is this worth submitting to the request queue?

You can put it in as an enhancement. However, I'd caution that there is 
more thinking to do here both in terms of the naming and how it fits in 
with future potential functionality.

Thinking of things as functions really isn't a good way to go - (sorry 
to 'bang the drum' slightly) but LiveCode is an English-like language 
and so we should be cautious adding any functions for which potential 
English-like syntax has not been determined.

Indeed, I always find that thinking in terms of English-like syntax 
tends to open eyes to potential variations.

For example adding 'lineAtOffset/wordAtOffset/itemAtOffset/...' seems 
quite ugly. However, imagine the syntax like this:

   the line containing x in y
   the word containing x in y
   the item containing x in y

Suddenly, a clear pattern starts to emerge and you can start to see what 
you could do if you just add adjectives, and prepositions:

   the last word containing x in y
   the first line containing x in y after index 2

Anyway, just my thoughts at the moment.

Warmest Regards,


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

More information about the use-livecode mailing list