Mike Schilling said:
It's extremely unintuitive, utterly useless, and a booby-trap for the
unwary. That makes it a misbehavior. So is the fact that casting a
I don't know. When I have a type that is *guarenteed* to always be passed by
copy, I would hope that I can understand that there is a difference between
a return value(which is a copy) and a field access(which is not). This is
absolutly the same as *every* other pass by value system I've ever seen.
Beyond that, it isn't useless. Why the hell have structs if they are pass by
reference as well? Your proposal entirely removes structures, and all their
benifits strictly because some people can't grasp what pass by value means.
That is their problem, not an issue with the language.
Do you even begin to understand the ramifications of what you are asking
for? Allowing this behavior would *fundamentally* change the language and
force alot of stupid hacks like cloning the object before returning it
because you can't be sure some yahoo wouldn't change a field . Also, what if
the function is
Point GetPoint()
{
Point p = new Point();
return p;
}
What is supposed to happen? is setting GetPoint().X supposed to assign
something in stack space that no longer exists? How is the user to know when
a structure is a field or in an array and when it is locally allocated in
the given method? How, at that, are we to maintain list rules where you
aren't allowed to modify the list?
The behavior you want is impossible and its really a bad idea to want it,
I'm afraid.
structure to an interface creates a copy of the structure. So are the
rules
for resolving overrides of overloaded methods in C#. The more
misbehaviors
Which rules are you concerned about?
it contains, the less usable a system is.
It stands to reason that the less logical the user is, the less likely he
can use the system as well.
All of these are "correct" in the sense that they're documented behavior,
but that's a different subject entirely.
Perhaps, although I don't think the documented behavior is a surprise...what
do you expect the language to be like?