<?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: Handle object as default class property value	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=handle-object-as-default-class-property-value</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sat, 16 Jan 2021 20:33:40 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Manzn		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-509758</link>

		<dc:creator><![CDATA[Manzn]]></dc:creator>
		<pubDate>Sat, 16 Jan 2021 20:33:40 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-509758</guid>

					<description><![CDATA[Thank you man! you saved me, when there was no more light :D]]></description>
			<content:encoded><![CDATA[<p>Thank you man! you saved me, when there was no more light 😀</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Sam Roberts		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-381756</link>

		<dc:creator><![CDATA[Sam Roberts]]></dc:creator>
		<pubDate>Wed, 29 Jun 2016 23:10:20 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-381756</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-381634&quot;&gt;Kyle&lt;/a&gt;.

Yes, R2016b has the same behaviour.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-381634">Kyle</a>.</p>
<p>Yes, R2016b has the same behaviour.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Kyle		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-381634</link>

		<dc:creator><![CDATA[Kyle]]></dc:creator>
		<pubDate>Tue, 28 Jun 2016 21:39:56 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-381634</guid>

					<description><![CDATA[Is anyone aware if this is still the behavior in the newest Matlab version, 2016b? We have a very large suite of classes that now need to be sifted through to verify we&#039;re not using this construction methodology. I&#039;d guess we probably aren&#039;t otherwise we&#039;d have seen an error by now, but who knows, because I don&#039;t know why we wouldn&#039;t. Default handle properties are certainly a typical use case and one would not expect said property to be the the same instance of in all calls.]]></description>
			<content:encoded><![CDATA[<p>Is anyone aware if this is still the behavior in the newest Matlab version, 2016b? We have a very large suite of classes that now need to be sifted through to verify we&#8217;re not using this construction methodology. I&#8217;d guess we probably aren&#8217;t otherwise we&#8217;d have seen an error by now, but who knows, because I don&#8217;t know why we wouldn&#8217;t. Default handle properties are certainly a typical use case and one would not expect said property to be the the same instance of in all calls.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Martin Lechner		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-348306</link>

		<dc:creator><![CDATA[Martin Lechner]]></dc:creator>
		<pubDate>Wed, 22 Apr 2015 07:38:48 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-348306</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-348133&quot;&gt;DNF&lt;/a&gt;.

That would be a very good solution for this issue. The default value for this property should be true because the described use cases where this Matlab behaviour is advantageous are only useful for some special tasks.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-348133">DNF</a>.</p>
<p>That would be a very good solution for this issue. The default value for this property should be true because the described use cases where this Matlab behaviour is advantageous are only useful for some special tasks.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ed Yu		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-348282</link>

		<dc:creator><![CDATA[Ed Yu]]></dc:creator>
		<pubDate>Tue, 21 Apr 2015 16:32:27 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-348282</guid>

					<description><![CDATA[To me this seems like a syntax issue... The behavior seems to be equivalent to Java&#039;s static class level properties instead of the regular object instance properties. I don&#039;t think the behavior absolutely needs to be changed but the way the declaration syntax should reflect this distinction. A feature? Definitely. But it introduces ambiguity. I agree with Yair that it&#039;s best to have it changed... At the very least, the syntax of a class level property (static?) should be different from an instance-level property initialized within the constructor. This will benefit programmers that come from OOP background; at the very least, Java programmers like myself.]]></description>
			<content:encoded><![CDATA[<p>To me this seems like a syntax issue&#8230; The behavior seems to be equivalent to Java&#8217;s static class level properties instead of the regular object instance properties. I don&#8217;t think the behavior absolutely needs to be changed but the way the declaration syntax should reflect this distinction. A feature? Definitely. But it introduces ambiguity. I agree with Yair that it&#8217;s best to have it changed&#8230; At the very least, the syntax of a class level property (static?) should be different from an instance-level property initialized within the constructor. This will benefit programmers that come from OOP background; at the very least, Java programmers like myself.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: DNF		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-348133</link>

		<dc:creator><![CDATA[DNF]]></dc:creator>
		<pubDate>Fri, 17 Apr 2015 14:19:06 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-348133</guid>

					<description><![CDATA[Might this not be handled by introducing a property attribute to determine the behaviour?

&lt;pre lang=&#039;matlab&#039;&gt;properties (InitializeForEachInstance = true)&lt;/pre&gt;

or something along those lines? I am quite unhappy with the current behaviour, and for my particular use I find the workaround (initializing in the constructor) to be ugly.]]></description>
			<content:encoded><![CDATA[<p>Might this not be handled by introducing a property attribute to determine the behaviour?</p>
<pre lang='matlab'>properties (InitializeForEachInstance = true)</pre>
<p>or something along those lines? I am quite unhappy with the current behaviour, and for my particular use I find the workaround (initializing in the constructor) to be ugly.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347895</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 11 Apr 2015 18:21:07 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-347895</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347850&quot;&gt;Dave Foti&lt;/a&gt;.

@Dave - thanks for the insight. I was hoping you&#039;d pitch in at some point, and I&#039;m happy that you did. I&#039;ve updated the post text with a corresponding addendum. I hope that you do add the MLint warning and preferably also the runtime console warning, so that users would no longer be confused. Once users are aware of the distinction between class load-time and instantiation-time defaults, I agree that this could well be put into good use.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347850">Dave Foti</a>.</p>
<p>@Dave &#8211; thanks for the insight. I was hoping you&#8217;d pitch in at some point, and I&#8217;m happy that you did. I&#8217;ve updated the post text with a corresponding addendum. I hope that you do add the MLint warning and preferably also the runtime console warning, so that users would no longer be confused. Once users are aware of the distinction between class load-time and instantiation-time defaults, I agree that this could well be put into good use.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347887</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Sat, 11 Apr 2015 17:02:23 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-347887</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347784&quot;&gt;Sam Roberts&lt;/a&gt;.

Thanks Sam - this is indeed a correct and important clarification.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347784">Sam Roberts</a>.</p>
<p>Thanks Sam &#8211; this is indeed a correct and important clarification.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dave Foti		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347851</link>

		<dc:creator><![CDATA[Dave Foti]]></dc:creator>
		<pubDate>Fri, 10 Apr 2015 21:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-347851</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347754&quot;&gt;Martin Lechner&lt;/a&gt;.

While handle ID&#039;s are not visible in MATLAB, == does compare two handle ID&#039;s, provided the specific handle class hasn&#039;t defined an override for the eq function.  This can be used to ask if two handles refer to the same object.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347754">Martin Lechner</a>.</p>
<p>While handle ID&#8217;s are not visible in MATLAB, == does compare two handle ID&#8217;s, provided the specific handle class hasn&#8217;t defined an override for the eq function.  This can be used to ask if two handles refer to the same object.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Dave Foti		</title>
		<link>https://undocumentedmatlab.com/articles/handle-object-as-default-class-property-value#comment-347850</link>

		<dc:creator><![CDATA[Dave Foti]]></dc:creator>
		<pubDate>Fri, 10 Apr 2015 21:42:44 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=5695#comment-347850</guid>

					<description><![CDATA[While I understand the source of confusion, I think Sam and Sebastian have provided most of the rationale for why MATLAB works the way it does.  The class definition is evaluated once while constructors are executable functions that execute every time an object is instantiated.  This gives the programmer the flexibility to choose whether an expression is evaluated once per class (in the definition) or once per object (in the constructor).  In addition to the referenced benefits of having expressions evaluated only once, the idea with the class definition is that it provides information that can be queried by tools and used to help document the class.  For example, because the &lt;code&gt;meta.property.DefaultValue&lt;/code&gt; is a value, you can compare this value to the current value of an object property and you can ask what value will I get if I create an object.  If default values are expressions that need to be evaluated every time, it is difficult for tools to query or display default values without causing unwanted side effects and a tool can&#039;t be sure what specific value a new instance will get by default.  

I agree that MATLAB could do a better job providing hints in the editor when assigning default values to handle objects or expressions that can return different values every time they are evaluated.]]></description>
			<content:encoded><![CDATA[<p>While I understand the source of confusion, I think Sam and Sebastian have provided most of the rationale for why MATLAB works the way it does.  The class definition is evaluated once while constructors are executable functions that execute every time an object is instantiated.  This gives the programmer the flexibility to choose whether an expression is evaluated once per class (in the definition) or once per object (in the constructor).  In addition to the referenced benefits of having expressions evaluated only once, the idea with the class definition is that it provides information that can be queried by tools and used to help document the class.  For example, because the <code>meta.property.DefaultValue</code> is a value, you can compare this value to the current value of an object property and you can ask what value will I get if I create an object.  If default values are expressions that need to be evaluated every time, it is difficult for tools to query or display default values without causing unwanted side effects and a tool can&#8217;t be sure what specific value a new instance will get by default.  </p>
<p>I agree that MATLAB could do a better job providing hints in the editor when assigning default values to handle objects or expressions that can return different values every time they are evaluated.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
