Re: Anders Hejlsberg comment on immutable objects
From: Martin Maat [EBL] (dummy_at_somewhere.nl)
Date: 02/09/04
- Next message: C# Learner: "Re: Adding Directory selection to FileOpenDialog"
- Previous message: Chuck: "Statement Completion -- Parameter Information problem"
- In reply to: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Next in thread: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Reply: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Reply: Will Dwinnell: "Re: Anders Hejlsberg comment on immutable objects"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 10 Feb 2004 00:26:27 +0100
"Magnus Lidbom" <magnus_lidbom@hotmail.com> wrote in message
news:tgkf20lr223jo6pb3kh6cqktq8c51ufkbo@4ax.com...
> I wrote a post, with a short comparison of const and read only
> interfaces, not long ago that you may find enlightening:
Okay, you compare using interfaces to the const keyword and conclude that
const is more concise and thus more powerful. It would be if it were the
same as using interfaces. The problem with const as I understand it is that
it will never be quite clear what exactly is to be considered const. The
implementor (or definor of the language if you will) has to choose a level
of protection ranging from just the object reference pointer (pretty
useless) to any dependencies one might access through the object. The latter
would be stronger but could turn out to be equally useless because it
ultimately would mean that the code querying the object should be denied
write access to anything, meaning it would not work.
I think the const concept just doesn't fit the object concept. Const is okay
for simple types but has no meaning to objects. In other words: it makes
sense for data but not for behavior.
It seems to me that if one says "it would be nice if we could apply const to
object arguments" one doesn't grasp the concequences.
I am not too confident myself here and the previous statement is not to say
you don't know what you are talking about (it sounds a bit like an insult),
my point is that I think once we apply const to objects, the possible
complexity is infinite and it would be impossible to implement (if you take
the protection serious anyway).
> Not really. He just pointed out the fact that you must distinguish the
> parameter from the object referenced by the parameter in the case of
> reference type parameters, and that the ref and out keywords doesn't
> help in managíng access to that object.
That is the issue, managing access to the object. I don't see how it could
be done because the compiler doesn't know what changes the object and what
doesn't. Like with the Sort method or retrieval of contained object
properties that may themselves expose write methods. The compiler could
never track that and sometimes it may not even make sense to do so. It would
be like asking the compiler to understand the semantics of your class and
then make judgements about what should be considered change and what should
not.
Some ten years ago the buz was fuzzy logic. It never took on. This reminds
me of fuzzy logic, I don't think I want it in C#.
Martin.
- Next message: C# Learner: "Re: Adding Directory selection to FileOpenDialog"
- Previous message: Chuck: "Statement Completion -- Parameter Information problem"
- In reply to: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Next in thread: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Reply: Magnus Lidbom: "Re: Anders Hejlsberg comment on immutable objects"
- Reply: Will Dwinnell: "Re: Anders Hejlsberg comment on immutable objects"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|