LiveCode 10 - what are your thoughts on the new features?
Mark Waddingham
mark at livecode.com
Wed Sep 8 12:09:28 EDT 2021
On 2021-09-08 16:48, Ben Rubinstein via use-livecode wrote:
>> It requires an explicit '...':
>
> Ahah! Not being a javascripter, I completely missed that, and thought
> you were just omitting some text for clarity!
>
> [Sidenote: what idiot decided to use ellipsis as an operator?? And not
> even the ellipsis character, but three dots???].
Well the heritage of 'triple dots' for such things goes back to C - and
I think the general idea is that its 'and the rest' (its used to mark
variadic functions there).
In terms of using it as the operator in this case:
foo a, b, ... tFoo
=> call foo with parameters a, b, 'and the rest' from tFoo
The reason why it isn't the ellipsis character is because it is
generally advised to ensure that all core syntax of a language can be
expressed in ASCII (for the antithesis of this idea - see APL!)
>> Interesting your missing of the all important operator being required
>> reminds
>> of a mistake I did make way back when I added the ability to use a
>> sequence
>> array as an array index...
>>
>> put tArray[tFoo] into tBar -- evaluates as tArray[1][2]
>
> What the... ? [insert joke here - I wrote that without realising what
> I'd done...]. I had no idea this facility existed. Is it documented
> anywhere?
I'm pretty sure you were one of the people who motivated it (the other
definitely being Trevor)...
It's definitely come up on the use-list before :D
It has been in the engine for years - maybe since 4.x or 5.x? The
addition was more than likely buried in the release notes though...
> Just to be clear, because the example below is ambiguous, given
>
> put "a" into tFoo[1]
> put "b" into tFoo[2]
>
> would
> put tArray[tFoo] into tBar
>
> evaluate as
> tArray["a"]["b"]
> or
> tArray[1][2]
>
> ?
The former - if an array is encountered in an index, and is a sequence,
the ordered sequence of values derived from the sequence is used as
extra components of the path. Indeed, this happens recursively IIRC -
i.e. if you have ['a', ['b', 'c'], 'd'] then the array path would be
[a][b][c][d].
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