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 ~ 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