<?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"
	>
<channel>
	<title>Comments on: C# Automatic Properties: Semantic changes to help cope with poor syntax?</title>
	<atom:link href="http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/feed/" rel="self" type="application/rss+xml" />
	<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/</link>
	<description>Closed weekends and holidays.</description>
	<pubDate>Sat, 17 May 2008 18:23:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=MU</generator>
		<item>
		<title>By: Bent</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-16346</link>
		<dc:creator>Bent</dc:creator>
		<pubDate>Sat, 06 Oct 2007 15:36:32 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-16346</guid>
		<description>I like it, becasue it just cuts down on what you need to write to get the job done, without hurting anyone. And it's pretty intuitive to understand.

What I don't like is that we have properties and also the readonly thing. Somehow I'd more like a unification of concepts.

Come to think of it, in Eiffel, you can't do this

a . b = c

unless

a = this

On the other hand, readonly is stricter yet, as it doesn't even allow methods in the same class to alter it - except constructors.

So if the new get-only pattern will generate a readonly variable, then that'd probably be a good thing, as it would automatically make the code more strict, I think.

I think Anders H. himself dislikes the "many ways to Rome" - meaning the syntax should be as canonical as possible without making it oversimplistic.

But you can question that with some of the syntax in C#.

Some syntax can seem arbitrary. But I suppose that's a characteristic of any ad-hoc language.

I vastly prefer C#'s properties to Java's reflection getX, setX, though. Even if it is a more canonical syntax (less is more). But less is more is only usable to a certain extent as not all of us enjoy brainfuck or assembler.</description>
		<content:encoded><![CDATA[<p>I like it, becasue it just cuts down on what you need to write to get the job done, without hurting anyone. And it&#8217;s pretty intuitive to understand.</p>
<p>What I don&#8217;t like is that we have properties and also the readonly thing. Somehow I&#8217;d more like a unification of concepts.</p>
<p>Come to think of it, in Eiffel, you can&#8217;t do this</p>
<p>a . b = c</p>
<p>unless</p>
<p>a = this</p>
<p>On the other hand, readonly is stricter yet, as it doesn&#8217;t even allow methods in the same class to alter it - except constructors.</p>
<p>So if the new get-only pattern will generate a readonly variable, then that&#8217;d probably be a good thing, as it would automatically make the code more strict, I think.</p>
<p>I think Anders H. himself dislikes the &#8220;many ways to Rome&#8221; - meaning the syntax should be as canonical as possible without making it oversimplistic.</p>
<p>But you can question that with some of the syntax in C#.</p>
<p>Some syntax can seem arbitrary. But I suppose that&#8217;s a characteristic of any ad-hoc language.</p>
<p>I vastly prefer C#&#8217;s properties to Java&#8217;s reflection getX, setX, though. Even if it is a more canonical syntax (less is more). But less is more is only usable to a certain extent as not all of us enjoy brainfuck or assembler.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BusinessRx Reading List : Automatic Properties</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-10722</link>
		<dc:creator>BusinessRx Reading List : Automatic Properties</dc:creator>
		<pubDate>Wed, 18 Jul 2007 02:22:49 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-10722</guid>
		<description>[...] Wandering Glitch: Semantic changes to help cope with poor syntax?      Published Tuesday, July 17, 2007 9:55 PM by OdeToCode [...]</description>
		<content:encoded><![CDATA[<p>[...] Wandering Glitch: Semantic changes to help cope with poor syntax?      Published Tuesday, July 17, 2007 9:55 PM by OdeToCode [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Hedgate</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2210</link>
		<dc:creator>Chris Hedgate</dc:creator>
		<pubDate>Sat, 24 Feb 2007 17:10:32 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2210</guid>
		<description>Payton, and others: Why is it an issue what name is given to the autogenerated, not visible in code, field? The meaning, to me, is that you don't use it. All access to it should go through the property, even inside the declaring class. That way you get full flexibility and no "lock-in" for the future.</description>
		<content:encoded><![CDATA[<p>Payton, and others: Why is it an issue what name is given to the autogenerated, not visible in code, field? The meaning, to me, is that you don&#8217;t use it. All access to it should go through the property, even inside the declaring class. That way you get full flexibility and no &#8220;lock-in&#8221; for the future.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joshmouch</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2197</link>
		<dc:creator>joshmouch</dc:creator>
		<pubDate>Fri, 16 Feb 2007 18:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2197</guid>
		<description>Even though I'm forced to use primarily C# in my work, I'm a VB.Net syntax lover.  So I look at this from a slightly different perspective, I think.

I like both the attribute idea and adding the "property" keyword idea.  I think the attribute idea is more flexible in that hopefully the Property attribute could be extended so that we could create our own property implementations (e.g. adding INotifyPropertyChanged).  However, I think the "property" keyword would be more consistent with the way C# works now (when comparing it to the "event" keyword).

In any case, I think the original proposed idea is awful.  It seems that  Ayende Rahien (no offense) is the only commenter to support it so far, so I hope it doesn't stick.

When I try to give definition to what is going on with the proposed way of adding automatic properties, I come up with "If the Member is not implemented and it does not have an abstract keyword then have the compiler do the work."

Here is that definition applied to an existing two different scenarios:

1) public abstract string MyProperty { get; set; }
This property is not implemented.  Fine.  It has an abstract keyword, so that's cool.
2) public string MyProperty { get; set; }
This property is not implented.  Fine.  Wait a minute... no abstract keyword.  I'll create the property for you!

So now apply this to a method.
1) public abstract void MyMethod();
This method is not implemented.  Fine.  It has an abstract keyword, so that's cool.
2) public void MyMethod();
This method is not implemented.  Fine.  Wait a minute... no abstract keyword.  I'll create the method for you!  Wait... umm.... how do I do that? ... should I do that?  What's going on?  INCONSISTENCIES!!! NOOOOO!!!! OMG!!! BOOOOM!

Now on the other hand consider these two lines:
public event MyEvent;
public property string MyProperty;

Both have similar syntaxes.  Both have automatically-generated code.  It's a perfect succession.


It only makes sense (to my VB.Net loving mind) that this be allowed to be explicitly defined as
public property string MyProperty { get{} set {} }

See the similarities(!!!!????):
public property string MyProperty;
public property string MyProperty { get{} set {} }

public event MyProperty;
public event MyProperty { add{} remove {} }


Ahh... my brain relaxes at the overwhelming consistency of the above four lines.  As Andrew said above, I'm completely against "continual cognitive dissonance"!

....
After writing all this, I decided my point would become clearer if I blogged some very concrete syntax examples.  They can be found here:
&lt;a href="http://joshmouch.wordpress.com/2007/02/16/syntax-consistency-among-class-members-events-properties-and-methods/" rel="nofollow"&gt;http://joshmouch.wordpress.com/2007/02/16/syntax-consistency-among-class-members-events-properties-and-methods/&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>Even though I&#8217;m forced to use primarily C# in my work, I&#8217;m a VB.Net syntax lover.  So I look at this from a slightly different perspective, I think.</p>
<p>I like both the attribute idea and adding the &#8220;property&#8221; keyword idea.  I think the attribute idea is more flexible in that hopefully the Property attribute could be extended so that we could create our own property implementations (e.g. adding INotifyPropertyChanged).  However, I think the &#8220;property&#8221; keyword would be more consistent with the way C# works now (when comparing it to the &#8220;event&#8221; keyword).</p>
<p>In any case, I think the original proposed idea is awful.  It seems that  Ayende Rahien (no offense) is the only commenter to support it so far, so I hope it doesn&#8217;t stick.</p>
<p>When I try to give definition to what is going on with the proposed way of adding automatic properties, I come up with &#8220;If the Member is not implemented and it does not have an abstract keyword then have the compiler do the work.&#8221;</p>
<p>Here is that definition applied to an existing two different scenarios:</p>
<p>1) public abstract string MyProperty { get; set; }<br />
This property is not implemented.  Fine.  It has an abstract keyword, so that&#8217;s cool.<br />
2) public string MyProperty { get; set; }<br />
This property is not implented.  Fine.  Wait a minute&#8230; no abstract keyword.  I&#8217;ll create the property for you!</p>
<p>So now apply this to a method.<br />
1) public abstract void MyMethod();<br />
This method is not implemented.  Fine.  It has an abstract keyword, so that&#8217;s cool.<br />
2) public void MyMethod();<br />
This method is not implemented.  Fine.  Wait a minute&#8230; no abstract keyword.  I&#8217;ll create the method for you!  Wait&#8230; umm&#8230;. how do I do that? &#8230; should I do that?  What&#8217;s going on?  INCONSISTENCIES!!! NOOOOO!!!! OMG!!! BOOOOM!</p>
<p>Now on the other hand consider these two lines:<br />
public event MyEvent;<br />
public property string MyProperty;</p>
<p>Both have similar syntaxes.  Both have automatically-generated code.  It&#8217;s a perfect succession.</p>
<p>It only makes sense (to my VB.Net loving mind) that this be allowed to be explicitly defined as<br />
public property string MyProperty { get{} set {} }</p>
<p>See the similarities(!!!!????):<br />
public property string MyProperty;<br />
public property string MyProperty { get{} set {} }</p>
<p>public event MyProperty;<br />
public event MyProperty { add{} remove {} }</p>
<p>Ahh&#8230; my brain relaxes at the overwhelming consistency of the above four lines.  As Andrew said above, I&#8217;m completely against &#8220;continual cognitive dissonance&#8221;!</p>
<p>&#8230;.<br />
After writing all this, I decided my point would become clearer if I blogged some very concrete syntax examples.  They can be found here:<br />
<a href="http://joshmouch.wordpress.com/2007/02/16/syntax-consistency-among-class-members-events-properties-and-methods/" rel="nofollow">http://joshmouch.wordpress.com/2007/02/16/syntax-consistency-among-class-members-events-properties-and-methods/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Syntax (+5 VB.Net) &#171; Joshua Mouch</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2196</link>
		<dc:creator>Syntax (+5 VB.Net) &#171; Joshua Mouch</dc:creator>
		<pubDate>Fri, 16 Feb 2007 18:06:16 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2196</guid>
		<description>[...] before you say, &#8220;but C# requires less typing, so that makes it better!&#8221;.&#160; Take this&#160;into account.&#160;C# will be adding an&#160;&#8221;Automatic Property&#8221; syntax.&#160; [...]</description>
		<content:encoded><![CDATA[<p>[...] before you say, &#8220;but C# requires less typing, so that makes it better!&#8221;.&nbsp; Take this&nbsp;into account.&nbsp;C# will be adding an&nbsp;&#8221;Automatic Property&#8221; syntax.&nbsp; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Matthews</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2107</link>
		<dc:creator>Andrew Matthews</dc:creator>
		<pubDate>Tue, 30 Jan 2007 22:44:36 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2107</guid>
		<description>Hi Antao,

I know what you mean. I used to pride myself on my pointer arithmetic. But on reflection, that's madness. I drive a car with an automatic gearbox because I'm confidant that it can change gears better than I can. The same ought to be true for the mindless drudgery of keeping track of objects. The nicest language ought to be the most transparent - the one where you have to think least of all about what the likely syntax fora given construct ought to be. When the language designers start adding non-intuitive syntaxes to save on typing, something's wrong.

As Ayende pointed out, there is a disambiguation in C# for non-implemented abstract properties - the abstract keyword. Although that is not necessary for interfaces (I have to admit I still think of interfaces as pure abstract classes, even though they're not in C#). I can't help feeling that if this trend of gilding the lily continues the language will be a mass of special cases, with a different thought process for each construct. the end result will be a continual cognitive dissonance, which will put people off it altogether.

I admit I'm being a little alarmist, but I still think that clarity ought to triumph over brevity!

As for unsigned types, I presume you mean that if you use System.Uint32 you are violating CLS compliance? I also wonder why they never included that as a requirement for the CLS... Of course if that is not an issue, then you can use it with impunity :-)

</description>
		<content:encoded><![CDATA[<p>Hi Antao,</p>
<p>I know what you mean. I used to pride myself on my pointer arithmetic. But on reflection, that&#8217;s madness. I drive a car with an automatic gearbox because I&#8217;m confidant that it can change gears better than I can. The same ought to be true for the mindless drudgery of keeping track of objects. The nicest language ought to be the most transparent - the one where you have to think least of all about what the likely syntax fora given construct ought to be. When the language designers start adding non-intuitive syntaxes to save on typing, something&#8217;s wrong.</p>
<p>As Ayende pointed out, there is a disambiguation in C# for non-implemented abstract properties - the abstract keyword. Although that is not necessary for interfaces (I have to admit I still think of interfaces as pure abstract classes, even though they&#8217;re not in C#). I can&#8217;t help feeling that if this trend of gilding the lily continues the language will be a mass of special cases, with a different thought process for each construct. the end result will be a continual cognitive dissonance, which will put people off it altogether.</p>
<p>I admit I&#8217;m being a little alarmist, but I still think that clarity ought to triumph over brevity!</p>
<p>As for unsigned types, I presume you mean that if you use System.Uint32 you are violating CLS compliance? I also wonder why they never included that as a requirement for the CLS&#8230; Of course if that is not an issue, then you can use it with impunity :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent Boogaart</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2106</link>
		<dc:creator>Kent Boogaart</dc:creator>
		<pubDate>Tue, 30 Jan 2007 22:11:47 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2106</guid>
		<description>Whoops, I meant I prefer this syntax:

public property string MyProperty;
 -or-
public readonly property string MyProperty;

because it is much more similar to how events are declared by default. And you could control serialization in the same way:

[field: NonSerialized]
public property string MyProperty;

I guess the difference comes about when you explicitly implement the property because you drop the "property" keyword, whereas you don't drop the "event" keyword when you explicitly implement an event:

public string MyProperty
{
   get { ... }
   set { ... }
}

Kent</description>
		<content:encoded><![CDATA[<p>Whoops, I meant I prefer this syntax:</p>
<p>public property string MyProperty;<br />
 -or-<br />
public readonly property string MyProperty;</p>
<p>because it is much more similar to how events are declared by default. And you could control serialization in the same way:</p>
<p>[field: NonSerialized]<br />
public property string MyProperty;</p>
<p>I guess the difference comes about when you explicitly implement the property because you drop the &#8220;property&#8221; keyword, whereas you don&#8217;t drop the &#8220;event&#8221; keyword when you explicitly implement an event:</p>
<p>public string MyProperty<br />
{<br />
   get { &#8230; }<br />
   set { &#8230; }<br />
}</p>
<p>Kent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Antao</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2105</link>
		<dc:creator>Antao</dc:creator>
		<pubDate>Tue, 30 Jan 2007 14:45:28 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2105</guid>
		<description>I loved C# when it came out. I loved that most common mistakes made in C++ where detected at compile time on C#. The ifs finally had to contain boolean expressions...

The only things missing were the generics and unsigned types on the framework. We no have the first but unfortunately we are not going to have the second one because of some other languages. Why the hell do we have to use int for the age of a person? I wish I didn't have to validate it...

Anyway, I think these last changes, like nameless delegates, will only confuse people. C# will end up like C++, too confusing...

Antao</description>
		<content:encoded><![CDATA[<p>I loved C# when it came out. I loved that most common mistakes made in C++ where detected at compile time on C#. The ifs finally had to contain boolean expressions&#8230;</p>
<p>The only things missing were the generics and unsigned types on the framework. We no have the first but unfortunately we are not going to have the second one because of some other languages. Why the hell do we have to use int for the age of a person? I wish I didn&#8217;t have to validate it&#8230;</p>
<p>Anyway, I think these last changes, like nameless delegates, will only confuse people. C# will end up like C++, too confusing&#8230;</p>
<p>Antao</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Matthews</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2089</link>
		<dc:creator>Andrew Matthews</dc:creator>
		<pubDate>Tue, 30 Jan 2007 04:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2089</guid>
		<description>LOL. Must be the C++ programmer coming out in me (in spirit, if not in syntax)</description>
		<content:encoded><![CDATA[<p>LOL. Must be the C++ programmer coming out in me (in spirit, if not in syntax)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kent Boogaart</title>
		<link>http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2083</link>
		<dc:creator>Kent Boogaart</dc:creator>
		<pubDate>Tue, 30 Jan 2007 02:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://aabs.wordpress.com/2007/01/29/c-automatic-properties-semantic-changes-to-help-cope-with-poor-syntax/#comment-2083</guid>
		<description>The reason using properties instead of fields is often useful is because you can later modify your property getter / setter without requiring that clients of your code be rebuilt. If you change a field to a property, you will have to rebuild all client code (often not possible if your code is a public library).

Whether this warrants more syntactic sugar is debatable, and I certainly don't like the proposed way of doing things. I'd much prefer:

public property string MyString { get; set; }

If you need to customize the backing field then write it. This is analogous to how events work:

public event EventHandler MyEvent; //uses the default backing store

public event EventHandler MyEvent
{ //use whatever backing store you want
   add {}
   remove {}
}

My 2c,
Kent</description>
		<content:encoded><![CDATA[<p>The reason using properties instead of fields is often useful is because you can later modify your property getter / setter without requiring that clients of your code be rebuilt. If you change a field to a property, you will have to rebuild all client code (often not possible if your code is a public library).</p>
<p>Whether this warrants more syntactic sugar is debatable, and I certainly don&#8217;t like the proposed way of doing things. I&#8217;d much prefer:</p>
<p>public property string MyString { get; set; }</p>
<p>If you need to customize the backing field then write it. This is analogous to how events work:</p>
<p>public event EventHandler MyEvent; //uses the default backing store</p>
<p>public event EventHandler MyEvent<br />
{ //use whatever backing store you want<br />
   add {}<br />
   remove {}<br />
}</p>
<p>My 2c,<br />
Kent</p>
]]></content:encoded>
	</item>
</channel>
</rss>
