From: Arved Sandstrom on 27 Feb 2010 18:30 Peter Duniho wrote: > Arved Sandstrom wrote: >> [...] >> That abbreviated syntax, which for you is the least useful aspect of >> properties in C#, may well be the most useful aspect of properties for >> most C# programmers. I doubt very much that the majority of C# writers >> are doing anything but jamming in those { get; set; } pairs for each >> field they want to expose. > > It has been my experience that that is _not_ how properties are > typically used (as I've already noted). [ SNIP ] It's all well and good, Peter, but it doesn't exactly lead me to believe that there are any deeper meanings to C# properties when someone like Brad Abrams, an important .NET program manager, describes .NET properties as syntactic sugar. What he said was, "Properties are like smart fields, is what I call them. They're just a way to put some sugar around fields." AHS
From: Peter Duniho on 27 Feb 2010 18:36 Arved Sandstrom wrote: > [...] it doesn't exactly lead me to believe > that there are any deeper meanings to C# properties when someone like > Brad Abrams, an important .NET program manager, describes .NET > properties as syntactic sugar. What he said was, "Properties are like > smart fields, is what I call them. They're just a way to put some sugar > around fields." If you want to base your entire understanding of the C# language on a single statement of a single individual at Microsoft, not even one who happens to be closely involved with the design of the language, I suppose that's your prerogative. No doubt, Brad Abrams is a reasonably smart person. But that doesn't mean he's the last word on language features, and even if he was, that doesn't mean you can gain a complete understanding of a feature by reading a single statement he's made. Pete
From: Arved Sandstrom on 27 Feb 2010 19:58 Peter Duniho wrote: > Arved Sandstrom wrote: >> [...] it doesn't exactly lead me to believe >> that there are any deeper meanings to C# properties when someone like >> Brad Abrams, an important .NET program manager, describes .NET >> properties as syntactic sugar. What he said was, "Properties are like >> smart fields, is what I call them. They're just a way to put some >> sugar around fields." > > If you want to base your entire understanding of the C# language on a > single statement of a single individual at Microsoft, not even one who > happens to be closely involved with the design of the language, I > suppose that's your prerogative. > > No doubt, Brad Abrams is a reasonably smart person. But that doesn't > mean he's the last word on language features, and even if he was, that > doesn't mean you can gain a complete understanding of a feature by > reading a single statement he's made. > > Pete Considering the position that Abrams held when he made that statement, and things like the fact that he's the primary author of the .NET Framework Design Guidelines, the Common Language Specification, and the class libraries for the ECMA CLI specification, I would myself take a statement like that quite seriously. And yes, it's a single statement. But not one that admits of ay other interpretation other than that Abrams thinks/thought that .NET properties are syntactic sugar. Granted, he is a single guy. And even an original language designer can be wrong about his or her own language, or misunderstand the path it's taken, so I do take your point to a certain degree. It's just that, try as I might, I don't see that there is anything more to C# properties than syntactic sugar. You mentioned perhaps some examples where the power of properties stands out - I wouldn't mind a cite, because nothing I can find on the MS sites is compelling. AHS
From: Peter Duniho on 28 Feb 2010 18:40 Arved Sandstrom wrote: > [...] > It's just that, try as I might, I don't see that there is anything more > to C# properties than syntactic sugar. You seem to be using an odd definition of "syntactic sugar". The usual, commonly accepted definition is of a language feature that accomplishes nothing more than could be accomplished with the language already using some other (usually more verbose) syntax. That commonly accepted definition precludes a feature like properties, where the compiled output from a program cannot be accomplished in any other way than the use of that feature in the language. It may be that YOU would never use properties in a way different from what you could accomplish functionally without them, but the fact remains that even if YOU were to use them, the compiled result would still be different from that than if you had just declared methods to accomplish the same, and the fact also remains that other people take advantage of that difference to accomplish things that cannot be accomplished using just methods named using a specific convention (even assuming you can count on them always using the same convention, which hasn't been the case even in the most carefully-written Java codeā¦even the JDK uses multiple getter naming conventions in different places). Pete
From: Arved Sandstrom on 28 Feb 2010 19:33
Peter Duniho wrote: > Arved Sandstrom wrote: >> [...] >> It's just that, try as I might, I don't see that there is anything >> more to C# properties than syntactic sugar. > > You seem to be using an odd definition of "syntactic sugar". The usual, > commonly accepted definition is of a language feature that accomplishes > nothing more than could be accomplished with the language already using > some other (usually more verbose) syntax. > > That commonly accepted definition precludes a feature like properties, > where the compiled output from a program cannot be accomplished in any > other way than the use of that feature in the language. [ SNIP ] The term "syntactic sugar" has nothing whatsoever to do with differences in compiled output. I agree entirely with your definition - it's the one I'm using. And that definition has nothing to do with object code/IL/bytecode differences. The fact is that you can replace every use of a C# property with either a public member field and/or a public method. That's why properties are syntactic sugar. AHS |