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


Array assignment / initialization [was Re: synonyms]

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

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 :-) ?


___
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