<div>Doubt im alone in saying that the record syntax is not only poor, but very acidic to erlang programming. It moves the balance of when you should stop using a tuple and over to a record strongly to the "il keep using a tuple thanks" end of things. There was one attempt ( maybe two ) to fix records but it had a few problems :</div>
<div><br></div><div>the good points:</div><div>1) the accessor pattern was great, and ever better for accessing records in records. something not easy in the regular syntax!!</div><div>2) its better than the normal record syntax!</div>
<div>3) it auto detected records, but just within that one function, by noticing the first time it was used as a record.</div><div>4) it added 0 performance penalty for using this new syntax</div><div><br></div><div>the not so good points :-) :</div>
<div><br></div><div>1) it was very unreliable, totally unrelated to records erlang code would randomly break and your left debugging a parse transform that's very deep, half way threw, all your code.</div><div>2) updater code was kinda bad & weird and also made other valid erlang code into something else</div>
<div>3) maybe a small point, but if you are shipping code to clients, they may not like code that ships with dependancies on unsupported parse-transform libraries</div><div>4) if you have one record that spans almost all your code in that module, you still have to repeat the fact its a record at least once in every function</div>
<div><br></div><div>here is is from all the way back in 2006 </div><div><br></div><div><a href="http://yarivsblog.blogspot.com/2006/10/recless-type-inferring-parse-transform.html">http://yarivsblog.blogspot.com/2006/10/recless-type-inferring-parse-transform.html</a></div>
<div><br></div><div>I know there has been some talk of a record replaclemnt in Erl/OTP but i am planing on producing my own in the meantime, from a *simplified* AST parse transform and the syntax would look like this:</div>
<div><br></div><div>> Accessing : Value = RecordTypeVariable.element1.sub_element_of_elemet_1 etc.. just like recless ( also without "=" match like do_func(RecordTypeVariable.element1) )</div><div>> No multiple access, its not really needed in this case</div>
<div>> Updating : NewRec = RecordTypeVariable(element1.sub_element_of_elemet_1="mynewvalue",element2="mynewvalue_for_element2").</div><div><br></div><div>This combines the record syntax with the fun syntax, so looks semi-familiar and importantly will not produce a syntax error before the parse transform ( otherwise i could have the updater with {}).</div>
<div>The alternate is to mix with record syntax with the (no so popular) PMod syntax like RecordTypeVar:rec_update(element1.elem1_sub_elem=....)</div><div><br></div><div>if the same record is used throughout, it would be possible, but entirly optional, to set a "global record" for the module, so any var name matching that "global record" would be auto set</div>
<div>eg :</div><div>-global_record(state,['State']). ( single quotes needed to make the capital value an atom )</div><div><br></div><div>Producing a revers that generates the original record syntax for shipping to clients would be useful i feel too!</div>
<div><br></div><div>So any thoughts on my updater syntax? or suggestions that could be better ( keeping i mind that it still has to pass the first step of parsing!)</div><div><br></div><div>James</div>