<div dir="ltr">Hi all,<div><br></div><div style>There are two schools of thought here. One would like to put all the data in a giant nested data structure and the other would like to split it up into the smallest possible parts. I think that was what David G. hinted at before, but he didn't put the final dot over the i.</div>
<div style><br></div><div style>Having a single huge immutable nested data structure would require the kind of access patterns exemplified by "character.current_weapon.score", but is not without other kind of problems. I can think of three important ones. (1) You would need another syntax for "character.bag_item(12).supply" or "character.friend('Bilbo').weapon", for example. This is alleviated by Joe's suggestion, where one can use all kind of selectors. (2) All updating must be done from the root or in several steps, so i f I have X=Character.weapon, X.score=10, I need to remember to Character.weapon=X. (3) Changing the implementation of an item to another data structure might be problematic without changing all the call sites.</div>
<div style><br></div><div style>On the other side, that David described, one could have a character process, a weapon process, a bag process and so on. Then, using a construct that Joe suggested oh so many years ago, you could write Character!!weapon!!score to retrieve it and Character!!weapon!!{score, 30} to set it. The !! operator is a 'rpc' and is conceptually a send followed by a receive. The processes will be effectively implement active objects.</div>
<div style><br></div><div style>My feeling is that the latter option is more Erlang-y, but it may be a matter of taste. </div><div style><br></div><div style>best regards,</div><div style>Vlad</div><div style><br></div></div>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 4:08 PM, Joe Armstrong <span dir="ltr"><<a href="mailto:erlang@gmail.com" target="_blank">erlang@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Manipulating nested records is a pain - how about this?</div><div><br></div><div>Assume we have three records</div><div><br></div><div>-record(top, {a::#one{}, b::#two{}, c::#three{} }).</div><div>-record(one, {x::#foo{}, y::#bar{} })</div>
<div>-record(foo, {p,q,r}).</div><div><span style="white-space:pre-wrap"> </span></div><div>and I want to unpack the p field from a variable X containing a top</div><div>record.</div><div class="im"><div><br></div><div>
I don't want to write</div><div> </div></div><div> #top{a=#one{x=#foo{p=P}}} = X</div><div><br></div><div>this is messy and error prone</div><div><br></div><div>This should do the job</div><div><br></div><div> P = extract_from(X, top,p)</div>
<div><br></div><div>A compile transform could figure out the code to make. In this case the</div><div>tag p has a unique path from the top root. In the case where the required</div><div>tag is not unique, we'll need to "hint" the path. </div>
<div><br></div><div>We just give the parse transform enough hints to figure out</div><div>the path at compile time. We should get a error if the path does not uniquely</div><div>specify the element.</div><div><br></div><div>
Cheers</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>/Joe</div></font></span><div class="HOEnZb"><div class="h5"><div><br></div><div><br></div><br><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 2:07 PM, Darach Ennis <span dir="ltr"><<a href="mailto:darach@gmail.com" target="_blank">darach@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi guys,<div><br></div><div>There is a problem here. Any reasonably sized or structured erlang application</div><div>requires records, despite the grody record syntax. The alternative? Big hairy unstructured</div>
<div>clods of tuple and lists and things? Worse. Unmaintainable in and of itself. Hard to pattern</div>
<div>match. Had to manipulate. Hard for humans to grok whilst reading without squinting your</div><div>brain hard and quizzically at the terminal ...</div><div><br></div><div>Unlike the matrix, it's not blonde, brunette or a redhead ... It's something else! ;(</div>
<div><br></div><div>So they're needed? Yes. Use by choice? No. And that's the problem.</div><div><br></div><div>I secretly hope for for something better to come along. A big gnarly unstructured</div><div>and frequently accessed tuple would be fine, for example, if there was some kind</div>
<div>of tuple path expression language... like XML has XPath? Jackpot.</div><div><br></div><div>So maybe frames aren't needed at all. Maybe frames would be nice. Perhaps we</div><div>just want to reach out and touch the a subset of tuples of lists of tuples of lists of</div>
<div>tuples of ... I'm pretty sure with or without frames that solves 80% of the need for me.</div><div><br></div><div>The other 20%? - Native support for Kaysian transforms and other natural conveniences</div><div>
for efficient slicing, dicing, filtering and merging.</div>
<div><br></div><div>I'm not sure record or any other syntax is actually the problem.</div><div><br></div><div>Also, the nice thing about adding something like an XPath like thing for tuples?</div><div>It doesn't break existing applications. It's backward compatible. It's forward</div>
<div>migratable. No new syntax because an expression can be a plain old list of</div><div>binary (string).</div><div><br></div><div>So, we maybe xmerl_xpath already has 99% of what's needed...</div><div><br></div><div>
Cheers,</div><div><br></div><div>Darach.</div><div><div><div><font color="#222222" face="arial, sans-serif"><br></font></div><div><br></div><div><br><div class="gmail_quote">On Fri, Jan 25, 2013 at 12:25 PM, Loïc Hoguin <span dir="ltr"><<a href="mailto:essen@ninenines.eu" target="_blank">essen@ninenines.eu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>On 01/25/2013 12:10 PM, Loïc Hoguin wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Let me tell you something about yourself.<br>
</blockquote>
<br></div>
I have been told this bit can be considered offensive in English, it isn't meant to be.<div><div><br>
<br>
-- <br>
Loïc Hoguin<br>
Erlang Cowboy<br>
Nine Nines<br>
<a href="http://ninenines.eu" target="_blank">http://ninenines.eu</a><br>
______________________________<u></u>_________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/<u></u>listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>
</div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>