<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Should M-Lint Try to Make a Recommendation?</title>
	<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/</link>
	<description>Loren Shure  works on design of the MATLAB language at &#60;a href="http://www.mathworks.com/"&#62;The MathWorks&#60;/a&#62;. She writes here about once a week on MATLAB programming and related topics. &#60;br&#62;&#60;br&#62;&#60;a href="/images/loren-full.jpg"&#62;&#60;img src="/images/loren.jpg"&#62;&#60;/a&#62;</description>
	<pubDate>Sun, 08 Nov 2009 05:52:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Alex</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24635</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Wed, 09 Jan 2008 22:33:59 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24635</guid>
		<description>In my opinion, marking obvious errors or code patterns that can be optimized to speed up code is very useful. However, a "teaching mode" or anything given advice on how to write code is pretty useless. 

From my own experience, when I was a beginner, I never understood these kind of messages or warnings and just ignored them. Later, when I learned more about programming and would be able to actually understand the messages, they usually didn't show up because I wrote better code or if they showed up, in 95% of the cases they annoyed me because I knew what I was doing.

Maybe I'm the exception to the rule, but an easy way to configure mlint would definitely be very helpful. 100 checkboxes where the user can check or uncheck every single message is not the way to go, though!</description>
		<content:encoded><![CDATA[<p>In my opinion, marking obvious errors or code patterns that can be optimized to speed up code is very useful. However, a &#8220;teaching mode&#8221; or anything given advice on how to write code is pretty useless. </p>
<p>From my own experience, when I was a beginner, I never understood these kind of messages or warnings and just ignored them. Later, when I learned more about programming and would be able to actually understand the messages, they usually didn&#8217;t show up because I wrote better code or if they showed up, in 95% of the cases they annoyed me because I knew what I was doing.</p>
<p>Maybe I&#8217;m the exception to the rule, but an easy way to configure mlint would definitely be very helpful. 100 checkboxes where the user can check or uncheck every single message is not the way to go, though!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24604</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Wed, 09 Jan 2008 13:25:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24604</guid>
		<description>Tim-

We have registered the request to catch specific errors.  I too think that would be a very nice feature, and, as you point out, help write concise code.

--Loren</description>
		<content:encoded><![CDATA[<p>Tim-</p>
<p>We have registered the request to catch specific errors.  I too think that would be a very nice feature, and, as you point out, help write concise code.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24602</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Wed, 09 Jan 2008 12:56:47 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24602</guid>
		<description>What about the unspoken "snippet #0" which is the way most MATLAB code is written:

doSomething ;
doMore ;

...in other words, code that is not embedded in any try/catch at all.   I can't imagine M-lint complaining here, as in "Warning: you have written code that uses the default MATLAB error/warning handler; this is a Really Bad Thing to do."

I think that attempts to let M-lint distinguish between snippet #1 and #2 will probably devolve into trying to distinguish between #1 and #0, which will not be helpful.

A better approach at the try/catch error handing would be to allow catch to catch only specified errors.  I have often written try/catch code, expecting one error, but had the catch find an error I didn't want to be caught.  I would rather just tell MATLAB to catch just the errors I want to catch, and let the default error handling process catch everything else.  It would be a lot simpler to code that way.

For example, if I'm running an experiment on lots of sparse test matrices, I want to catch the out-of-memory condition, skip that matrix, and keep going with other test matrices.  What I would really like to specify is something like this:

for k = 1:nmat
   try
      get the kth matrix
      run an experiment on the kth matrix
   catch 'MATLAB:nomem'
      oops, out of memory.  Just keep going.
   end
end

Then if I encounter an unexpected error, MATLAB will properly terminate my code.  To do this with the current try/catch, I must use "catch ME" (sounds like a line from the movie "Enchanted") and then check ME to see if it's what I expected and then explicitly throw an error if it isn't  Hmm, did I expect ME or someone else ;-) ?.  That's tedious, and tweaking  M-lint won't be of much help, I think.</description>
		<content:encoded><![CDATA[<p>What about the unspoken &#8220;snippet #0&#8243; which is the way most MATLAB code is written:</p>
<p>doSomething ;<br />
doMore ;</p>
<p>&#8230;in other words, code that is not embedded in any try/catch at all.   I can&#8217;t imagine M-lint complaining here, as in &#8220;Warning: you have written code that uses the default MATLAB error/warning handler; this is a Really Bad Thing to do.&#8221;</p>
<p>I think that attempts to let M-lint distinguish between snippet #1 and #2 will probably devolve into trying to distinguish between #1 and #0, which will not be helpful.</p>
<p>A better approach at the try/catch error handing would be to allow catch to catch only specified errors.  I have often written try/catch code, expecting one error, but had the catch find an error I didn&#8217;t want to be caught.  I would rather just tell MATLAB to catch just the errors I want to catch, and let the default error handling process catch everything else.  It would be a lot simpler to code that way.</p>
<p>For example, if I&#8217;m running an experiment on lots of sparse test matrices, I want to catch the out-of-memory condition, skip that matrix, and keep going with other test matrices.  What I would really like to specify is something like this:</p>
<p>for k = 1:nmat<br />
   try<br />
      get the kth matrix<br />
      run an experiment on the kth matrix<br />
   catch &#8216;MATLAB:nomem&#8217;<br />
      oops, out of memory.  Just keep going.<br />
   end<br />
end</p>
<p>Then if I encounter an unexpected error, MATLAB will properly terminate my code.  To do this with the current try/catch, I must use &#8220;catch ME&#8221; (sounds like a line from the movie &#8220;Enchanted&#8221;) and then check ME to see if it&#8217;s what I expected and then explicitly throw an error if it isn&#8217;t  Hmm, did I expect ME or someone else ;-) ?.  That&#8217;s tedious, and tweaking  M-lint won&#8217;t be of much help, I think.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24477</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 07 Jan 2008 14:07:38 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24477</guid>
		<description>Daniel-

Part of the issue with GUIDE is that it isn't generating "up-to-date" code.   We know about that and have plans to fix the generated code so it doesn't trigger M-Lint messages (though that's NOT the reason for the rewrite -- the reason is that we can generate what we think IS better code).  Not sure what release this will show up in....

--Loren</description>
		<content:encoded><![CDATA[<p>Daniel-</p>
<p>Part of the issue with GUIDE is that it isn&#8217;t generating &#8220;up-to-date&#8221; code.   We know about that and have plans to fix the generated code so it doesn&#8217;t trigger M-Lint messages (though that&#8217;s NOT the reason for the rewrite &#8212; the reason is that we can generate what we think IS better code).  Not sure what release this will show up in&#8230;.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Armyr</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24476</link>
		<dc:creator>Daniel Armyr</dc:creator>
		<pubDate>Mon, 07 Jan 2008 14:03:42 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24476</guid>
		<description>This is somewhat related to problem of the MS Word grammer check. People edit their text untill the grammer check is satisfied, but until the text is a good one. I am personally a fan of extremely stringent code, but there is a limit. One example I see is when using GUIDE. M-lint complains about the unused variable which comes with every function and finally I have so many %#ok in my code that I have practically disabled M-lint.

--DA</description>
		<content:encoded><![CDATA[<p>This is somewhat related to problem of the MS Word grammer check. People edit their text untill the grammer check is satisfied, but until the text is a good one. I am personally a fan of extremely stringent code, but there is a limit. One example I see is when using GUIDE. M-lint complains about the unused variable which comes with every function and finally I have so many %#ok in my code that I have practically disabled M-lint.</p>
<p>&#8211;DA</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob S.</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24425</link>
		<dc:creator>Rob S.</dc:creator>
		<pubDate>Sun, 06 Jan 2008 15:23:40 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24425</guid>
		<description>Great topic...

What about a macro-type setting in the preference for how "aggressive" mlint should behave.  A slider from "silent" to "teaching mode" and a few in between could satisfy how we each want to use code checking at different times. Each strictness level could have presets for the individual checks and messages being on or off.

Best,
Rob</description>
		<content:encoded><![CDATA[<p>Great topic&#8230;</p>
<p>What about a macro-type setting in the preference for how &#8220;aggressive&#8221; mlint should behave.  A slider from &#8220;silent&#8221; to &#8220;teaching mode&#8221; and a few in between could satisfy how we each want to use code checking at different times. Each strictness level could have presets for the individual checks and messages being on or off.</p>
<p>Best,<br />
Rob</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24357</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Sat, 05 Jan 2008 02:06:20 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24357</guid>
		<description>One downside to making m-lint more stringent is that it is overly critical of older code, particularly for code that is written to port to older versions of MATLAB.  For example, I find that I often have to include %#ok statements whenever I use "if (a &#124; b)", since m-lint complains that I should use "&#124;&#124;".  Well, "&#124;&#124;" doesn't exist in older MATLAB versions, so I must use it.  Keeping M-lint quiet is important, since it otherwise wants to say my code is cruddy when posted to the File Exchange.

As an example, see Nick Higham's Matrix Computation Toolbox, or Cleve Moler's NCM toolbox.  Both are excellent codes, but get dinged in the File Metrics by an overly-aggressive M-lint.  They were written before "&#124;&#124;" and "&#38;&#38;" were added to the language.  Nick's code also uses the old-style warnings, but M-lint complains there, too.

So, M-lint is made more stringent, then I would recommend not making these settings the default ... or at least exclude them from File Metrics posted on the File Exchange.</description>
		<content:encoded><![CDATA[<p>One downside to making m-lint more stringent is that it is overly critical of older code, particularly for code that is written to port to older versions of MATLAB.  For example, I find that I often have to include %#ok statements whenever I use &#8220;if (a | b)&#8221;, since m-lint complains that I should use &#8220;||&#8221;.  Well, &#8220;||&#8221; doesn&#8217;t exist in older MATLAB versions, so I must use it.  Keeping M-lint quiet is important, since it otherwise wants to say my code is cruddy when posted to the File Exchange.</p>
<p>As an example, see Nick Higham&#8217;s Matrix Computation Toolbox, or Cleve Moler&#8217;s NCM toolbox.  Both are excellent codes, but get dinged in the File Metrics by an overly-aggressive M-lint.  They were written before &#8220;||&#8221; and &#8220;&amp;&amp;&#8221; were added to the language.  Nick&#8217;s code also uses the old-style warnings, but M-lint complains there, too.</p>
<p>So, M-lint is made more stringent, then I would recommend not making these settings the default &#8230; or at least exclude them from File Metrics posted on the File Exchange.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John D'Errico</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24356</link>
		<dc:creator>John D'Errico</dc:creator>
		<pubDate>Sat, 05 Jan 2008 01:56:47 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24356</guid>
		<description>The repmat/bsxfun one is an excellent idea. Virtually anywhere you see a repmat, bsxfun probably could be applied with better results.

How about a check for an H1 line?

I did know about being able to turn off the warnings, but I'd never known I could do it via a right click. Neat.

John</description>
		<content:encoded><![CDATA[<p>The repmat/bsxfun one is an excellent idea. Virtually anywhere you see a repmat, bsxfun probably could be applied with better results.</p>
<p>How about a check for an H1 line?</p>
<p>I did know about being able to turn off the warnings, but I&#8217;d never known I could do it via a right click. Neat.</p>
<p>John</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan K</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24342</link>
		<dc:creator>Dan K</dc:creator>
		<pubDate>Fri, 04 Jan 2008 21:33:57 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24342</guid>
		<description>How about replacing repmat with bsxfun?  That's a pretty trivial one.

Dan</description>
		<content:encoded><![CDATA[<p>How about replacing repmat with bsxfun?  That&#8217;s a pretty trivial one.</p>
<p>Dan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24336</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 04 Jan 2008 17:58:19 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/01/04/should-mlint-recommend/#comment-24336</guid>
		<description>John and Dan, 

Thanks for the comments so far.  

Do you know you can turn messages off from the preferences panel or right-clicking on the message and choosing to have that topic not reported on?  That way, even if mlint does have more "style" messages, you can still regulate your interaction with them.

As for performance, if we can identify some code patterns that would be more optimally done another way, we can add those to mlint.  But it needs to be a pattern (even if complex).  Any candidates?

--Loren</description>
		<content:encoded><![CDATA[<p>John and Dan, </p>
<p>Thanks for the comments so far.  </p>
<p>Do you know you can turn messages off from the preferences panel or right-clicking on the message and choosing to have that topic not reported on?  That way, even if mlint does have more &#8220;style&#8221; messages, you can still regulate your interaction with them.</p>
<p>As for performance, if we can identify some code patterns that would be more optimally done another way, we can add those to mlint.  But it needs to be a pattern (even if complex).  Any candidates?</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
</channel>
</rss>
