<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Data Binding Associative Arrays in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Data-Binding-Associative-Arrays/m-p/35814#M21123</link>
    <description>&lt;P&gt;I recently had need to create some slightly complex data structures and started to play with associative arrays a little more. &amp;nbsp;These are similar to dictionaries in other languages. &amp;nbsp;Where they differ is that most languages to improve speed, when assigning an object in a dictionary to a variable it does a data binding. &amp;nbsp;Essentially it makes it so both the dictionary and the variable refer to the same block of memory and any edits to one affects the other. &amp;nbsp;However, JMP doesn't do this. &amp;nbsp;Below is some example code to help explain what I'm talking about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;testAA = Associative Array(
	{
		{"test1", Associative Array(
			{{"data", {"data1", "data2"}}}
		)},
		{"test2", Associative Array(
			{{"data", {"data1", "data2"}}}
		)}
	}
);
//create new object
AA = testAA["test1"];
//adding data to AA doesn't add data to testAA
AA["newData"] = "newData";
//you can see AA is a new object
print(AA, testAA);
//Work around to ensure data structures are in sync
testAA["test1"] = AA;
print(AA, testAA);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think JSL as a language would want this behavior as a default. &amp;nbsp;I say that, b/c this can be confusing to many new programmers and JSL especially has many non-programmers enthuists. &amp;nbsp;However, this logic is applied to Data Tables. &amp;nbsp;AKA:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test = New Table("Hello");
test2 = test;
test &amp;lt;&amp;lt; New Column("NewColumn");
print(test2 &amp;lt;&amp;lt; Get Column Names);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think it would be really nice if there was another assignment operator that would make references to data objects if needed. &amp;nbsp;This way I could choose if I want a new object or a reference to the other one. &amp;nbsp;I would be interested in others thoughts on the subject. &amp;nbsp;Also, I could be completely wrong and there may be a way to hack the associative arrays to do this that I haven't found yet.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Feb 2017 21:53:50 GMT</pubDate>
    <dc:creator>msharp</dc:creator>
    <dc:date>2017-02-14T21:53:50Z</dc:date>
    <item>
      <title>Data Binding Associative Arrays</title>
      <link>https://community.jmp.com/t5/Discussions/Data-Binding-Associative-Arrays/m-p/35814#M21123</link>
      <description>&lt;P&gt;I recently had need to create some slightly complex data structures and started to play with associative arrays a little more. &amp;nbsp;These are similar to dictionaries in other languages. &amp;nbsp;Where they differ is that most languages to improve speed, when assigning an object in a dictionary to a variable it does a data binding. &amp;nbsp;Essentially it makes it so both the dictionary and the variable refer to the same block of memory and any edits to one affects the other. &amp;nbsp;However, JMP doesn't do this. &amp;nbsp;Below is some example code to help explain what I'm talking about.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;testAA = Associative Array(
	{
		{"test1", Associative Array(
			{{"data", {"data1", "data2"}}}
		)},
		{"test2", Associative Array(
			{{"data", {"data1", "data2"}}}
		)}
	}
);
//create new object
AA = testAA["test1"];
//adding data to AA doesn't add data to testAA
AA["newData"] = "newData";
//you can see AA is a new object
print(AA, testAA);
//Work around to ensure data structures are in sync
testAA["test1"] = AA;
print(AA, testAA);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I don't think JSL as a language would want this behavior as a default. &amp;nbsp;I say that, b/c this can be confusing to many new programmers and JSL especially has many non-programmers enthuists. &amp;nbsp;However, this logic is applied to Data Tables. &amp;nbsp;AKA:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;test = New Table("Hello");
test2 = test;
test &amp;lt;&amp;lt; New Column("NewColumn");
print(test2 &amp;lt;&amp;lt; Get Column Names);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think it would be really nice if there was another assignment operator that would make references to data objects if needed. &amp;nbsp;This way I could choose if I want a new object or a reference to the other one. &amp;nbsp;I would be interested in others thoughts on the subject. &amp;nbsp;Also, I could be completely wrong and there may be a way to hack the associative arrays to do this that I haven't found yet.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Feb 2017 21:53:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Data-Binding-Associative-Arrays/m-p/35814#M21123</guid>
      <dc:creator>msharp</dc:creator>
      <dc:date>2017-02-14T21:53:50Z</dc:date>
    </item>
  </channel>
</rss>

