Is C# 2.0 syntax of Properties closed?

  • Thread starter Thread starter =?ISO-8859-2?Q?Marcin_Grz=EAbski?=
  • Start date Start date
Jon Skeet said:
But those qualities *are* just the syntactic qualities - they're just
easier syntax for calling the methods. In what way *isn't* that
syntactic sugar, albeit very "good" sugar? As you say later on, there's
extra CLR support for properties, but I would say that at least
*nearly* all the stuff that makes them appear field-like is just
syntactic sugar.

I'll agree, with the caveat that a property is there strictly to provide
field like access, which I consider a bit ironic. A property is a set of
methods that exist so that languages can treat them like fields
syntactically
Agreed :)


And I'd be happy with that - it's when people claim that a property is
more "field-like" than "pair-of-methods-like" that I have problems,
because it's *only* the syntax which is field-like, not the semantics.

In the language, which is what the original post was about at that, syntax
tends to matter a bit more than semantics. In programming the semantics
matter more.
Sure.



That's fine - the fact that they're compiled to methods is all that I
would particularly urge people to know. The fact that they have
semantics which are very close to methods is important - the rest is
only important to a few people who are either doing low-level stuff or
are just incorrigibly nosy, like ourselves. :)

Being nosy has its perks, ;)
Yes, there definitely more to it than *just* syntactic sugar -
apologies for the previous over-generalisation. The bits that make them
look like fields are just syntactic sugar though, IMO :)

Yes, that I'll agree on.
 
Jon Skeet said:
But those qualities *are* just the syntactic qualities - they're just
easier syntax for calling the methods. In what way *isn't* that
syntactic sugar, albeit very "good" sugar? As you say later on, there's
extra CLR support for properties, but I would say that at least
*nearly* all the stuff that makes them appear field-like is just
syntactic sugar.

But these syntactic qualities reach very far. You can bind a
collection with object instances of a class with properties to a grid
without having to implement ITypedList to produce custom property
descriptors which call into the methods.

It's easier, but not just 'easier', it helps tremendously in some
areas as the usage of classes in a data-binding scenario can become very
complex (ITypedList is no picknick)

So this sugar tastes really good :) (and is IMHO far less sugar
than, say, foreach)
And I'd be happy with that - it's when people claim that a property is
more "field-like" than "pair-of-methods-like" that I have problems,
because it's *only* the syntax which is field-like, not the semantics.

Agreed! :)

FB
 
I don't regard the phrase "syntactic sugar" as derogatory like some
people do, btw. The using(...) statement is syntactic sugar, but
incredibly useful - just like properties. That said, I think it's
important to recognise syntactic sugar for what it is, and know what
lies behind it.


The whole OOP itself (objects, interfaces,virtual methods..) is just
syntactic sugar. You could do everything by yourself, building your own
vtables and so on.
All higher level programming languages are only syntactical sugar that makes
inputting machine instructions in the computer easier than per hand.

But syntactical sugar is good when it makes the code more readable and
selfexplanory so idea of properties looking like fields is not that bad.
The only problem is that you never know wheather a call to a certain propery
is a simple field access internally or wheather the property most do
expensive calculation to return you the value you want. But the same problem
you would have with an old school getter method so who cares.
 
Wow!

I didn't expect that this thread discussion takes so far...
far... from my question.

Really i want to ask You (group) for personal feeling
of new concept of Properties syntax.

My todays "C# code rules" are standing before serious question:
where the new "two accesors" properties would fit?

Marcin

PS: I know that my english is weak... but i can try to
explain any question :)
 
Back
Top