Array assignment / initialization [was Re: synonyms]
Alex Tweedly
alex at tweedly.net
Wed Jun 28 18:32:40 EDT 2017
On 28/06/2017 16:55, Richard Gaskin via use-livecode wrote:
>
> Fully agreed, as I wrote in my post introducing this arg format to the
> discussion a couple days ago:
>
> And as much as I like it in R, I'm not sure I would advocate it
> in an xTalk as any sort of necessity. It might be ideal for
> certain types of commands (oh how I'd love it with "export"),
> but is so unusual compared to most other languages that it may
> just increase the learning curve for most folks.
I don't accept that named parameters are "unusual" nowadays.
They're in Python, Csharp, R and (if my quick Google got it right) Swift
- so that 's 5 of the top 20 most "popular" languages now, so I would
expect that a fairly high proportion of potential LC users would be
familiar with them.
> More with-the-grain would be this fourth option, passing in an array
> as we see with some existing LC commands and functions, but that
> requires a LOT more typing:
>
> put "my chart" into tA["name"]
> put 100 into tA["width"]
> put "This is a chart" into tA["label"]
> DoSomething tA
>
Yes, it would be nice if we had an easier (terser) way to assign to an
array. Maybe something like Python / Perl use to assign to a dictionary.
put { "name": "my chart", "width": 100, "label": "This is a chart",
"anarray": sAMine } into tA
DoSomething tA
-- Alex.
btw - whose bright idea was it to not put a 'sharp' key visible on a
British Mac keyboard :-) ?
More information about the use-livecode
mailing list