"lineAtOffset"?

Mark Waddingham mark at livecode.com
Thu Oct 29 16:06:23 EDT 2015


On 2015-10-29 20:33, Richard Gaskin wrote:
> I like the compactness, but have mixed feelings about the semantics.

I think it is less compact than a function form with appropriately 
chosen name (or suitable English-like syntax). Semantics wise it is 
introducing dynamicity in a case where there is absolutely no need for 
it...

> We might consider using a fourth argument for return type and leave
> the third for starting offset, but given how frequently offset is used
> without a specified start I'd guess most of the time it'd just be an
> empty arg:
> 
>   get lineoffset("foo", tText,"","text")

For me, this fails two 'tests' one could imagine for choosing syntax:

1) It makes an operation which is 'static' (i.e. chosen at the point of 
compilation) 'dynamic' (needing switching at runtime to perform). Now 
dynamicity is very important in making generalization possible. However, 
in this case, there isn't really a reasonable case for it - if "text" is 
specified as the final parameter then it will return a string, if not it 
will return a number. These two different things make it unlikely that 
at a single point of code you would need to choose dynamically (as 
supporting code would need to be different) and such you are taking the 
performance impact of dynamicity in a case where it would never be used.

2) It is likely that the "text" option will see almost as much use as 
the non-"text" option (which is why - beyond performance reasons - there 
is definitely an abstraction lurking that deserves its own form) but 
with the modification needed to make it uniform we end up with a 
situation where one option is significantly more difficult to access 
than the other.

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