[Exceptional C++ Style] Fw: const data - was Item 17
Kevlin Henney
kevlin at curbralan.com
Thu Dec 30 03:35:35 EST 2004
In message <41D3231F.5070109 at jaggersoft.com>, Jon Jagger
<jon at jaggersoft.com> writes
>Kevlin Henney wrote:
>
>>> This depends on the language. In C# (CLR) the proxying facilities
>>>allow interception. I could intercept field access if I wanted to.
>>>And yes I do mean fields and not properties (of course I could
>>>intercept properties too if I wanted). There would be no change
>>>required to the users code.
>>
>> True, but the representation of the field must still exist for it to
>>be intercepted, and anything much beyond operationally as opposed to
>>functionally related extension of semantics might be considered
>>surprising unless that is an accepted part of the architecture.
>>
>I can use public fields, public properties, or public getter methods.
>Whichever I choose the representation of the chosen thing must still
>exist and (in the CLR) all three have scope for extension. Surely any
>operational extension would be pretty much equally acceptable in all
>three cases and any functional extension would be equally unacceptable
>in all three cases?
Yes, as I said, anything beyond operational extensions would be
surprising, which means functional extensions -- apologies that my
phrasing was unclear.
>These public fields are in a class and the class _does_ have an
>interface. But clearly the fields are not in the interface. And neither
>are any properties. So what is in the interface? Answer, an indexer.
>You provide a string name and the subclass provides the non-terminal
>with that name. Why do I have this? Because it proved wonderfully
>useful in XML driven test code (for example).
I'm confused. Clearly public fields and properties _are_ in the
interface, and adding an indexer simply extends the public interface.
What have I misunderstood in your phrasing?
>The natural syntax is, I still maintain, field-like access.
Not when the natural mode of access is not field based. In an OO
language without properties or parentheses for argumentless methods, the
'natural' syntax is to use access that looks method based. In a language
that supports them the argument is precisely the opposite!
Kevlin
--
____________________________________________________________
Kevlin Henney phone: +44 117 942 2990
mailto:kevlin at curbralan.com mobile: +44 7801 073 508
http://www.curbralan.com fax: +44 870 052 2289
Curbralan: Consultancy + Training + Development + Review
____________________________________________________________
More information about the Effective-cpp
mailing list