Re: Array assignment / initialization [was Re: synonyms]

2017-06-29 Thread Mark Wieder via use-livecode

On 06/28/2017 03:32 PM, Alex Tweedly via use-livecode wrote:

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.


...and ruby. Let's not forget ruby. Ruby allows for

DoSomething name: "my chart", width: 100, label: "This is a chart", 
annaray: sAMine




put { "name": "my chart", "width": 100, "label": "This is a chart", 
"anarray": sAMine } into tA

DoSomething tA


LCB lets you do just that. And I'm promised that *someday* the LCB 
syntax will morph into the fabled Open Language project that's used as 
the excuse not to fix these anomalies.


--
 Mark Wieder
 ahsoftw...@gmail.com

___
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


Re: Array assignment / initialization [was Re: synonyms]

2017-06-29 Thread Alex Tweedly via use-livecode

On 28/06/2017 23:32, Alex Tweedly via use-livecode wrote:
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

OK, here I go answering my own post (again).

function _
  local tA
  repeat with i = 1 to paramcount()
 put param(i+1) into tA[param(i)]
  end repeat
  return tA
end _

and then I can do

put _("name","my chart",   "width",100,   "label","This is a chart",   
"anarray",sAMine) into tA

DoSomething tA

or, indeed, even

DoSomething  _("name","my chart",   "width",100,   "label","This is a 
chart",   "anarray",sAMine)


Still doesn't handle pass-by-reference - but that's a problem even with 
variable numbers of params in LC, so I'll accept it for this case.


-- Alex.

___
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