title: Erlang record to tuple list
body: <p>I'm trying to work out a macro definition that will turn a record into a tuple list. Something like:</p>
  
  <pre><code>&gt; Id = #id{id1=1,id2=2,id3=3}.
  {id,1,2,3}
  &gt; ?record_to_tuplelist(id,Id).
  [{id1,1},{id2,2},{id3,3}]
  </code></pre>
  
  <p>So far I worked out this:</p>
  
  <pre><code>-define(record_to_tuplelist(Rec,RecRef), [ {X,RecRef#Rec.X} || X &lt;- record_info(fields,Rec) ]).
  </code></pre>
  
  <p>But it gives a syntax error. If I change RecRef#Rec.X to RecRef#Rec{} it works, but doesn't return what I want. Is this just an obscure syntax error or is this actually not possible?</p>