<div class="gmail_quote">On Sun, May 22, 2011 at 6:26 PM, Robert Virding <span dir="ltr"><<a href="mailto:robert.virding@erlang-solutions.com">robert.virding@erlang-solutions.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">I think the actual syntax is the least of your problems. The existing syntax looks like it does much because of the properties of erlang and of records. Records were added to give named fields to tuples and to be at least as fast as directly using the tuple operations. This means that everything had to be done at compile-time. And as erlang is dynamically typed without any typed declarations then all type information has to be given at each record operation.<br>
<br>Recless tried to be smart and get around this and only require the field names and not the record names. There are really only two ways of doing this properly:<br><br>1. Require that all field names are unique in all records.<br>
2. Require some typing "help" so the system can work out which record types are being accessed.<br><br></div></div></blockquote><div><br>I'm not sure why I have Haskell so much on my mind these days, but anyway: #1 is precisely what Haskell does. In addition, as shown in my example below, field names live in the same namespace as variables. It is not my favorite feature in that language.<br>
<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div style="font-family: Times New Roman; font-size: 12pt; color: rgb(0, 0, 0);">
The first is very difficult to work with in any large project. It would even be difficult for all OTP records. The second would mean requiring static type declarations to work properly and in all situations, which would be a fundamental change to the current Erlang language. It would, in fact, be a new language.<br>
<br>Another thing to be aware of is that pattern matching and '=' complicate the syntax. I personally don't think that<br><br><code><font size="3">NewProject = Project.owner.address.city = "Boston".</font><br>
<br><span style="font-family: times new roman,new york,times,serif;">is that much more intelligible.</span><br style="font-family: times new roman,new york,times,serif;"></code><br></div></div></blockquote><div><br>Just for fun, in Haskell this currently looks like:<br>
<br>newProject = project { owner = (owner project) { address = (address (owner project)) { city = "Boston" }}}<br><br>Not pretty.<br><br>Then again, is it common to need to do nested updates of fields like that?<br>
<br> dan<br></div></div><br>