common code patterns

Alex Tweedly alex at tweedly.net
Fri Aug 11 20:17:15 EDT 2017



On 11/08/2017 23:17, Monte Goulding via use-livecode wrote:
>> On 11 Aug 2017, at 9:40 am, Alex Tweedly via use-livecode <use-livecode at lists.runrev.com> wrote:
>>
>> repeat with i=1 to paramcount()-1
>>             put param(i)&"," after theValue
>> end repeat
>> put param(paramcount()) after theValue
>>
>> Shorter, faster, and just plain tidier :-)
> Hmm… there’s a few reasons I’m not a fan of this pattern:
>
> - you can’t really clearly document the handler parameters although this could feasibly be worked around by redefining what a parameter is in your docs
Well, it's not my pattern (in fact, initially I didn't even spot that it 
did this "trick" to handle a point) - so I may be the wrong one to 
defend it - but here goes.

The common use case is where the parameters are any one of
  - one or two points
  - a rect
  - one to four coords
(i.e. anywhere you are basically passing in a rectangle in the various 
common flavours).

I think I've seen it in  few places (presumably Geometry Engine, maybe 
one of the chart libraries, etc.)

-- Alex.




More information about the use-livecode mailing list