title: Can I pass a simple value by reference in ColdFusion?
body: <p>By default, ColdFusion passes simple types (like numeric, string, and GUID) by value to functions.  I'd like to pass a simple type by reference.  </p>
  
  <p>I'm currently wrapping a simple value in a struct (they get passed by reference).  This solves my problem but it is very ugly:</p>
  
  <pre><code>&lt;!--- TheFunctionName----&gt;
  &lt;cffunction name="TheFunctionName"&gt;
       &lt;cfargument name="OutVariable" type="struct"&gt;
       &lt;cfset OutVariable.ID = 5&gt;
  &lt;/cffunction&gt;
  
  &lt;cfset OutVariable=StructNew()&gt;
  &lt;cfset TheFunctionName(OutVariable)&gt;
  
  &lt;!--- I want this to output 5---&gt;
  &lt;cfoutput&gt;#OutVariable.ID#&lt;/cfoutput&gt;
  </code></pre>
  
  <p>I'd rather something like this:</p>
  
  <pre><code>&lt;!--- TheFunctionName----&gt;
  &lt;cffunction name="TheFunctionName"&gt;
       &lt;cfargument name="OutVariable" passbyref="true"&gt;
       &lt;cfset OutVariable = 5&gt;
  &lt;/cffunction&gt;
  
  &lt;cfset TheFunctionName(OutVariable)&gt;
  
  &lt;!--- I want this to output 5---&gt;
  &lt;cfoutput&gt;#OutVariable#&lt;/cfoutput&gt;
  </code></pre>