<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: cfinvoke destroys returnVariable for methods that return void</title>
	<atom:link href="http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void</link>
	<description></description>
	<lastBuildDate>Thu, 01 Jun 2017 18:51:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Brian Kotek</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-54405</link>
		<dc:creator>Brian Kotek</dc:creator>
		<pubDate>Tue, 24 Feb 2009 15:40:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-54405</guid>
		<description>Hmm, no tags allowed, apparently? In pseudocode then:

set var local = StructNew()

cfinvoke .... returnVariable=&quot;local.output&quot;

if( StructKeyExists( local, &#039;output&#039; )
return output
else
return</description>
		<content:encoded><![CDATA[<p>Hmm, no tags allowed, apparently? In pseudocode then:</p>
<p>set var local = StructNew()</p>
<p>cfinvoke &#8230;. returnVariable=&#8221;local.output&#8221;</p>
<p>if( StructKeyExists( local, &#8216;output&#8217; )<br />
return output<br />
else<br />
return</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Kotek</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-54404</link>
		<dc:creator>Brian Kotek</dc:creator>
		<pubDate>Tue, 24 Feb 2009 15:38:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-54404</guid>
		<description>CF has done this since CFCs were introduced, actually. It isn&#039;t specific to cfinvoke. If you call any CFC method, in any way, that returns void and attempt to assign it to a variable, you&#039;ll get an error if you try to reference that variable.

I&#039;m also not sure what using cfexit does within a method call like that, I&#039;d use a void cfreturn or, better, throw an exception.

I would modify your code to omit IsDefined(), since that can easily give you unexpected results because it implicitly checks multiple scopes looking for the variable. Do something like



  
  
	
  
	
  </description>
		<content:encoded><![CDATA[<p>CF has done this since CFCs were introduced, actually. It isn&#8217;t specific to cfinvoke. If you call any CFC method, in any way, that returns void and attempt to assign it to a variable, you&#8217;ll get an error if you try to reference that variable.</p>
<p>I&#8217;m also not sure what using cfexit does within a method call like that, I&#8217;d use a void cfreturn or, better, throw an exception.</p>
<p>I would modify your code to omit IsDefined(), since that can easily give you unexpected results because it implicitly checks multiple scopes looking for the variable. Do something like</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Nadel</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-53895</link>
		<dc:creator>Ben Nadel</dc:creator>
		<pubDate>Fri, 30 Jan 2009 13:20:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-53895</guid>
		<description>@Brian,

Hmmm, not sure on that. Maybe.</description>
		<content:encoded><![CDATA[<p>@Brian,</p>
<p>Hmmm, not sure on that. Maybe.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-53875</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Thu, 29 Jan 2009 18:55:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-53875</guid>
		<description>@Ben - understood - I&#039;m referring to the memory leak issues that people experience with CFCs and un-var&#039;d variables eating memory.  Would making them NULL accomplish the same thing?   This is really just a technical curiosity on my part... wondering how CF is working under the covers.</description>
		<content:encoded><![CDATA[<p>@Ben &#8211; understood &#8211; I&#8217;m referring to the memory leak issues that people experience with CFCs and un-var&#8217;d variables eating memory.  Would making them NULL accomplish the same thing?   This is really just a technical curiosity on my part&#8230; wondering how CF is working under the covers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Nadel</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-53855</link>
		<dc:creator>Ben Nadel</dc:creator>
		<pubDate>Wed, 28 Jan 2009 13:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-53855</guid>
		<description>Brian, the reason to var scope a variable is to make sure the one you are using is meant to be local to the method only. If you do NOT var and simply destroy variables, you run the risk of destroying a globally-accessible variable.</description>
		<content:encoded><![CDATA[<p>Brian, the reason to var scope a variable is to make sure the one you are using is meant to be local to the method only. If you do NOT var and simply destroy variables, you run the risk of destroying a globally-accessible variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: brian</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-53839</link>
		<dc:creator>brian</dc:creator>
		<pubDate>Wed, 28 Jan 2009 01:45:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-53839</guid>
		<description>Agreed - in retrospect it makes sense but it&#039;s strange to have your variable, already defined, disappear.

Technical curiosity: we all know that we need to var scope our function variables.  Could you accomplish the same thing by, instead of var-ing them at the top of the function, JavaCast-ing them to NULL at the end?</description>
		<content:encoded><![CDATA[<p>Agreed &#8211; in retrospect it makes sense but it&#8217;s strange to have your variable, already defined, disappear.</p>
<p>Technical curiosity: we all know that we need to var scope our function variables.  Could you accomplish the same thing by, instead of var-ing them at the top of the function, JavaCast-ing them to NULL at the end?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Mandel</title>
		<link>http://www.ghidinelli.com/2009/01/27/cfinvoke-destroys-returnvariable-for-methods-that-return-void/comment-page-1#comment-53838</link>
		<dc:creator>Mark Mandel</dc:creator>
		<pubDate>Wed, 28 Jan 2009 01:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.ghidinelli.com/?p=542#comment-53838</guid>
		<description>That is because a &#039;void&#039; function will return &#039;null&#039;.

Any value in CF that is &#039;null&#039; doesn&#039;t technically exist, as far as CF is concerned, so you get interesting stuff like the above.

You can test this my assigning a variable the value of Javacast(&quot;null&quot;, &quot;&quot;) and watch it dissapear

Fun, no?</description>
		<content:encoded><![CDATA[<p>That is because a &#8216;void&#8217; function will return &#8216;null&#8217;.</p>
<p>Any value in CF that is &#8216;null&#8217; doesn&#8217;t technically exist, as far as CF is concerned, so you get interesting stuff like the above.</p>
<p>You can test this my assigning a variable the value of Javacast(&#8220;null&#8221;, &#8220;&#8221;) and watch it dissapear</p>
<p>Fun, no?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
