<?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: Callback functions performance	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/callback-functions-performance/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/callback-functions-performance?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=callback-functions-performance</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Thu, 26 Sep 2019 10:07:12 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Jan K		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-499944</link>

		<dc:creator><![CDATA[Jan K]]></dc:creator>
		<pubDate>Thu, 26 Sep 2019 10:07:12 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-499944</guid>

					<description><![CDATA[While the obj.function vs function(obj) times are almost identical for Matlab code (see i.e. the discussion here: https://stackoverflow.com/a/1745686/3620376), it&#039;s not solved for called .NET (C#) code. The results were quite clear, in my case 35.57 seconds (Net 4.5 obj.nop()) vs 8.72 seconds (Net 4.5 nop(obj)).
I&#039;ve made an update to Andrew Janke&#039;s repo at https://github.com/apjanke/matlab-bench to test that.
.

Even more interesting is the fact, that a event callback, thrown in .NET and caught in Matlab is slower when it&#039;s an pure function handle. It&#039;s marginal but visible and contrary to your example above, where you state, that all anonymous function calls should be replaced by non-anonymous ones if possible.
.

&#039;DataIsReady&#039; is a .NET Framework 4.5 (C#) event. I&#039;m at Matlab 2019b @ windows 10.

&lt;pre lang=&quot;matlab&quot;&gt;
% somewhere in a handle class
lis = addlistener(evnt, &#039;DataIsReady&#039;, @obj.onSerialBytesAvailableNet);

...
function onSerialBytesAvailableNet(obj, src, evnt)
     obj.cnt = obj.cnt + 1;
end
&lt;/pre&gt;

vs

&lt;pre lang=&quot;matlab&quot;&gt;
% somewhere in a handle class
lis = addlistener(evnt, &#039;DataIsReady&#039;, @(src,evnt)obj.onSerialBytesAvailableNet(src,evnt)); % faster than the rest!
...
function onSerialBytesAvailableNet(obj, src, evnt)
     obj.cnt = obj.cnt + 1;
end
&lt;/pre&gt;

Profiler times:
...j.onSerialBytesAvailableNet(src,evnt) 40807 8.369 s 0.220 s
...nSerialBytesAvailableNet(varargin{:}) 38265 8.407 s 0.347 s

Looks like the addlistener calls the function with varargin{:} when a non-anonymous function is used. I don&#039;t know if that&#039;s special for .NET events or default, but it&#039;s more than 50 % slower in my case.
I know, there is a big number of function calls, and probably not worth mentioning or impacting performance but just figured that out and wanted to hear you comments :)

Thanks]]></description>
			<content:encoded><![CDATA[<p>While the obj.function vs function(obj) times are almost identical for Matlab code (see i.e. the discussion here: <a href="https://stackoverflow.com/a/1745686/3620376" rel="nofollow ugc">https://stackoverflow.com/a/1745686/3620376</a>), it&#8217;s not solved for called .NET (C#) code. The results were quite clear, in my case 35.57 seconds (Net 4.5 obj.nop()) vs 8.72 seconds (Net 4.5 nop(obj)).<br />
I&#8217;ve made an update to Andrew Janke&#8217;s repo at <a href="https://github.com/apjanke/matlab-bench" rel="nofollow ugc">https://github.com/apjanke/matlab-bench</a> to test that.<br />
.</p>
<p>Even more interesting is the fact, that a event callback, thrown in .NET and caught in Matlab is slower when it&#8217;s an pure function handle. It&#8217;s marginal but visible and contrary to your example above, where you state, that all anonymous function calls should be replaced by non-anonymous ones if possible.<br />
.</p>
<p>&#8216;DataIsReady&#8217; is a .NET Framework 4.5 (C#) event. I&#8217;m at Matlab 2019b @ windows 10.</p>
<pre lang="matlab">
% somewhere in a handle class
lis = addlistener(evnt, 'DataIsReady', @obj.onSerialBytesAvailableNet);

...
function onSerialBytesAvailableNet(obj, src, evnt)
     obj.cnt = obj.cnt + 1;
end
</pre>
<p>vs</p>
<pre lang="matlab">
% somewhere in a handle class
lis = addlistener(evnt, 'DataIsReady', @(src,evnt)obj.onSerialBytesAvailableNet(src,evnt)); % faster than the rest!
...
function onSerialBytesAvailableNet(obj, src, evnt)
     obj.cnt = obj.cnt + 1;
end
</pre>
<p>Profiler times:<br />
&#8230;j.onSerialBytesAvailableNet(src,evnt) 40807 8.369 s 0.220 s<br />
&#8230;nSerialBytesAvailableNet(varargin{:}) 38265 8.407 s 0.347 s</p>
<p>Looks like the addlistener calls the function with varargin{:} when a non-anonymous function is used. I don&#8217;t know if that&#8217;s special for .NET events or default, but it&#8217;s more than 50 % slower in my case.<br />
I know, there is a big number of function calls, and probably not worth mentioning or impacting performance but just figured that out and wanted to hear you comments 🙂</p>
<p>Thanks</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-395459</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Wed, 07 Dec 2016 14:18:55 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-395459</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-395443&quot;&gt;Alex&lt;/a&gt;.

@Alex - there is no immediate answer. If you want me to look at your specific code, then email me (altmany at gmail) for a dedicated consulting session.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-395443">Alex</a>.</p>
<p>@Alex &#8211; there is no immediate answer. If you want me to look at your specific code, then email me (altmany at gmail) for a dedicated consulting session.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Alex		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-395443</link>

		<dc:creator><![CDATA[Alex]]></dc:creator>
		<pubDate>Wed, 07 Dec 2016 10:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-395443</guid>

					<description><![CDATA[I&#039;ve tried to adapt the function callback for my GUI designed with GUIDE. I&#039;ve adapted 
&lt;pre lang=&quot;matlab&quot;&gt;@(hObject,eventdata)CAEQE(&#039;testListBox1_Callback&#039;,hObject,eventdata,guidata(hObject))&lt;/pre&gt;
to 
&lt;pre lang=&quot;matlab&quot;&gt;@testListBox1_Callback&lt;/pre&gt;
inside of my main code. 
But in my case it won&#039;t work to get the Callback faster. Can you help? 

Alex]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve tried to adapt the function callback for my GUI designed with GUIDE. I&#8217;ve adapted </p>
<pre lang="matlab">@(hObject,eventdata)CAEQE('testListBox1_Callback',hObject,eventdata,guidata(hObject))</pre>
<p>to </p>
<pre lang="matlab">@testListBox1_Callback</pre>
<p>inside of my main code.<br />
But in my case it won&#8217;t work to get the Callback faster. Can you help? </p>
<p>Alex</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin Afanasjew		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357785</link>

		<dc:creator><![CDATA[Martin Afanasjew]]></dc:creator>
		<pubDate>Sun, 27 Sep 2015 13:34:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357785</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063&quot;&gt;Martin Afanasjew&lt;/a&gt;.

@Yair – there are probably many variants I haven&#039;t tested. If I have a function used internally by a single class, then I fully agree with you. However, the exercise here was to create a function handle that forwards its arguments to a method of a class while passing an instance of that class as the first argument. And I fail to see how your suggestion could be used in this scenario, or am I misunderstanding you?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063">Martin Afanasjew</a>.</p>
<p>@Yair – there are probably many variants I haven&#8217;t tested. If I have a function used internally by a single class, then I fully agree with you. However, the exercise here was to create a function handle that forwards its arguments to a method of a class while passing an instance of that class as the first argument. And I fail to see how your suggestion could be used in this scenario, or am I misunderstanding you?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357781</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sun, 27 Sep 2015 11:55:50 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357781</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357779&quot;&gt;Martin Afanasjew&lt;/a&gt;.

You are missing one important variant, that I expect to be the fastest of all: &lt;code&gt;@plus&lt;/code&gt; where &lt;code&gt;plus(obj,x)&lt;/code&gt; is a sub-function in the same class file as the main class, but implemented as a separate sub-function rather than a class method. This avoids the two most important method-invocation performance hotspots: anonymous functions and class methods. For any performance-critical code that is repeatedly invoked in class methods, I often use such sub-functions (or standalone procedural functions).]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357779">Martin Afanasjew</a>.</p>
<p>You are missing one important variant, that I expect to be the fastest of all: <code>@plus</code> where <code>plus(obj,x)</code> is a sub-function in the same class file as the main class, but implemented as a separate sub-function rather than a class method. This avoids the two most important method-invocation performance hotspots: anonymous functions and class methods. For any performance-critical code that is repeatedly invoked in class methods, I often use such sub-functions (or standalone procedural functions).</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin Afanasjew		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357779</link>

		<dc:creator><![CDATA[Martin Afanasjew]]></dc:creator>
		<pubDate>Sun, 27 Sep 2015 11:49:30 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357779</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063&quot;&gt;Martin Afanasjew&lt;/a&gt;.

I finally ran a simple benchmark (on OS X 10.10.5) to support my argument. It also very nicely shows the performance improvements in R2015b.

In the benchmark &lt;code&gt;obj&lt;/code&gt; is an instance of a custom polynomial class and &lt;code&gt;x&lt;/code&gt; is a double scalar. The work done in the &lt;code&gt;plus&lt;/code&gt; method is minor, so the performance is dominated by the function/method call overhead. Every run consists of a thousand invocations of the “function handle” created before the loop.

Results after 10 runs (in 84.13s) on MATLAB R2015a:
&lt;pre&gt;
&#124; Variant                  &#124; Average &#124;    Best &#124;   Worst &#124;
&#124; @(x) obj.plus(x)         &#124;   2.08s &#124;   2.04s &#124;   2.31s &#124;
&#124; @obj.plus                &#124;   2.09s &#124;   2.05s &#124;   2.24s &#124;
&#124; @(x) plus(obj, x)        &#124;   1.72s &#124;   1.70s &#124;   1.75s &#124;
&#124; MethodHandle(obj, @plus) &#124;   1.76s &#124;   1.73s &#124;   1.80s &#124;
&lt;/pre&gt;

Results after 10 runs (in 47.81s) on MATLAB R2015b:
&lt;pre&gt;
&#124; Variant                  &#124; Average &#124;    Best &#124;   Worst &#124;
&#124; @(x) obj.plus(x)         &#124;   1.28s &#124;   1.26s &#124;   1.29s &#124;
&#124; @obj.plus                &#124;   1.29s &#124;   1.28s &#124;   1.33s &#124;
&#124; @(x) plus(obj, x)        &#124;   0.86s &#124;   0.84s &#124;   0.89s &#124;
&#124; MethodHandle(obj, @plus) &#124;   0.91s &#124;   0.90s &#124;   0.92s &#124;
&lt;/pre&gt;

The last line was initially a silly experiment, that turned out to be surprisingly fast. It is a class that holds an object instance and a function handle and overrides the &lt;code&gt;subsref&lt;/code&gt; method to provide a function-handle-like interface. In the end &lt;code&gt;MethodHandle(obj, @method)&lt;/code&gt; should behave like &lt;code&gt;@(varargin) method(obj, varargin{:})&lt;/code&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063">Martin Afanasjew</a>.</p>
<p>I finally ran a simple benchmark (on OS X 10.10.5) to support my argument. It also very nicely shows the performance improvements in R2015b.</p>
<p>In the benchmark <code>obj</code> is an instance of a custom polynomial class and <code>x</code> is a double scalar. The work done in the <code>plus</code> method is minor, so the performance is dominated by the function/method call overhead. Every run consists of a thousand invocations of the “function handle” created before the loop.</p>
<p>Results after 10 runs (in 84.13s) on MATLAB R2015a:</p>
<pre>
| Variant                  | Average |    Best |   Worst |
| @(x) obj.plus(x)         |   2.08s |   2.04s |   2.31s |
| @obj.plus                |   2.09s |   2.05s |   2.24s |
| @(x) plus(obj, x)        |   1.72s |   1.70s |   1.75s |
| MethodHandle(obj, @plus) |   1.76s |   1.73s |   1.80s |
</pre>
<p>Results after 10 runs (in 47.81s) on MATLAB R2015b:</p>
<pre>
| Variant                  | Average |    Best |   Worst |
| @(x) obj.plus(x)         |   1.28s |   1.26s |   1.29s |
| @obj.plus                |   1.29s |   1.28s |   1.33s |
| @(x) plus(obj, x)        |   0.86s |   0.84s |   0.89s |
| MethodHandle(obj, @plus) |   0.91s |   0.90s |   0.92s |
</pre>
<p>The last line was initially a silly experiment, that turned out to be surprisingly fast. It is a class that holds an object instance and a function handle and overrides the <code>subsref</code> method to provide a function-handle-like interface. In the end <code>MethodHandle(obj, @method)</code> should behave like <code>@(varargin) method(obj, varargin{:})</code>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357132</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 17 Sep 2015 17:11:32 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357132</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357131&quot;&gt;Chris Guenther&lt;/a&gt;.

@Chris - this is a limitation of GUIDE. You can modify the callbacks programmatically in your GUIDE-generated m-file (&lt;i&gt;Main_Program.m&lt;/i&gt;), for example in the OpeningFcn(). In this function, all the other subfunctions of the m-file are in scope and so you can directly set the relevant callbacks to their direct function handles.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357131">Chris Guenther</a>.</p>
<p>@Chris &#8211; this is a limitation of GUIDE. You can modify the callbacks programmatically in your GUIDE-generated m-file (<i>Main_Program.m</i>), for example in the OpeningFcn(). In this function, all the other subfunctions of the m-file are in scope and so you can directly set the relevant callbacks to their direct function handles.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Chris Guenther		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357131</link>

		<dc:creator><![CDATA[Chris Guenther]]></dc:creator>
		<pubDate>Thu, 17 Sep 2015 17:05:28 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357131</guid>

					<description><![CDATA[I&#039;m using GUIDE for creating GUIs, and by default they do this for callbacks:
&lt;pre lang=&quot;matlab&quot;&gt;@(hObject,eventdata)Main_Program(&#039;button_name_Callback&#039;,hObject,eventdata,guidata(hObject))&lt;/pre&gt;
I tried changing this to &lt;code&gt;@button_name_Callback&lt;/code&gt;, but it seems that where it&#039;s evaluating the callbacks, functions like &lt;code&gt;button_name_Callback&lt;/code&gt; inside &lt;code&gt;Main_Program&lt;/code&gt; are out of scope.  Is this a limitation of GUIDE, or do you know if there some way I can make this work?]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m using GUIDE for creating GUIs, and by default they do this for callbacks:</p>
<pre lang="matlab">@(hObject,eventdata)Main_Program('button_name_Callback',hObject,eventdata,guidata(hObject))</pre>
<p>I tried changing this to <code>@button_name_Callback</code>, but it seems that where it&#8217;s evaluating the callbacks, functions like <code>button_name_Callback</code> inside <code>Main_Program</code> are out of scope.  Is this a limitation of GUIDE, or do you know if there some way I can make this work?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin Afanasjew		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357064</link>

		<dc:creator><![CDATA[Martin Afanasjew]]></dc:creator>
		<pubDate>Wed, 16 Sep 2015 15:59:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357064</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063&quot;&gt;Martin Afanasjew&lt;/a&gt;.

One more note about the performance implications of changing &lt;i&gt;@(h, e) obj.tableDeletedCallbackFcn(e)&lt;/i&gt; to &lt;i&gt;@obj.tableDeletedCallbackFcn&lt;/i&gt; (example from the article):

I fail to see why this should improve performance at all. My doubts stem from the fact that the latter looks like a simple function handle, but in fact turns out to be an anonymous function handle. MATLAB R2015b prints: &lt;i&gt;@(varargin)obj.tableDeletedCallbackFcn(varargin{:})&lt;/i&gt;. So this only saves us from having to write out the arguments. And calling &lt;i&gt;functions&lt;/i&gt; (a function that offers a glimpse at the internal representation of function handles) on that also confirms the type to be “anonymous”. From a conceptual point of view it has to be that way, because anonymous function handles are the only type capable of storing some workspace alongside the function handle. And, well, there&#039;s this &lt;i&gt;obj&lt;/i&gt; that needs to be stored somewhere.

I have to admit, that I haven&#039;t benchmarked theses different versions, though. So maybe structurally there should be no big difference, but in fact there is.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063">Martin Afanasjew</a>.</p>
<p>One more note about the performance implications of changing <i>@(h, e) obj.tableDeletedCallbackFcn(e)</i> to <i>@obj.tableDeletedCallbackFcn</i> (example from the article):</p>
<p>I fail to see why this should improve performance at all. My doubts stem from the fact that the latter looks like a simple function handle, but in fact turns out to be an anonymous function handle. MATLAB R2015b prints: <i>@(varargin)obj.tableDeletedCallbackFcn(varargin{:})</i>. So this only saves us from having to write out the arguments. And calling <i>functions</i> (a function that offers a glimpse at the internal representation of function handles) on that also confirms the type to be “anonymous”. From a conceptual point of view it has to be that way, because anonymous function handles are the only type capable of storing some workspace alongside the function handle. And, well, there&#8217;s this <i>obj</i> that needs to be stored somewhere.</p>
<p>I have to admit, that I haven&#8217;t benchmarked theses different versions, though. So maybe structurally there should be no big difference, but in fact there is.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin Afanasjew		</title>
		<link>https://undocumentedmatlab.com/articles/callback-functions-performance#comment-357063</link>

		<dc:creator><![CDATA[Martin Afanasjew]]></dc:creator>
		<pubDate>Wed, 16 Sep 2015 15:30:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5996#comment-357063</guid>

					<description><![CDATA[Note also that there&#039;s a subtle difference between &lt;i&gt;obj.myCallback()&lt;/i&gt; and &lt;i&gt;myCallback(obj)&lt;/i&gt;. The former explicitly states that a method of &lt;i&gt;obj&lt;/i&gt; should be called (MATLAB won&#039;t search anywhere else to find a &lt;i&gt;myCallback&lt;/i&gt;). In contrast, the latter version could call a regular function or a method of &lt;i&gt;obj&lt;/i&gt;. So I wouldn&#039;t recommend switching between them blindly, even if the result is very likely to be the same.

If multiple arguments were involved, like in &lt;i&gt;myCallback(a, b, c)&lt;/i&gt;, and arguments had different type, there would be even more possibilities for what gets called. E.g., if &lt;i&gt;c&lt;/i&gt; had a higher precedence than the other two arguments, then the method from the class of &lt;i&gt;c&lt;/i&gt; would be picked, if available. (See the &lt;i&gt;InferiorClasses&lt;/i&gt; attribute used with &lt;i&gt;classdef&lt;/i&gt; and also “Class Precedence” in the MATLAB documentation. The concept is called multiple dispatch, which is not a very common programming language feature, but makes a lot of sense in an environment geared towards scientific computing.)

These subtleties are probably not very relevant in the context of callbacks, but it is good to be aware of them nonetheless.]]></description>
			<content:encoded><![CDATA[<p>Note also that there&#8217;s a subtle difference between <i>obj.myCallback()</i> and <i>myCallback(obj)</i>. The former explicitly states that a method of <i>obj</i> should be called (MATLAB won&#8217;t search anywhere else to find a <i>myCallback</i>). In contrast, the latter version could call a regular function or a method of <i>obj</i>. So I wouldn&#8217;t recommend switching between them blindly, even if the result is very likely to be the same.</p>
<p>If multiple arguments were involved, like in <i>myCallback(a, b, c)</i>, and arguments had different type, there would be even more possibilities for what gets called. E.g., if <i>c</i> had a higher precedence than the other two arguments, then the method from the class of <i>c</i> would be picked, if available. (See the <i>InferiorClasses</i> attribute used with <i>classdef</i> and also “Class Precedence” in the MATLAB documentation. The concept is called multiple dispatch, which is not a very common programming language feature, but makes a lot of sense in an environment geared towards scientific computing.)</p>
<p>These subtleties are probably not very relevant in the context of callbacks, but it is good to be aware of them nonetheless.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
