Re: c# features
- From: "Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Fri, 21 Mar 2008 11:58:05 -0700
On Fri, 21 Mar 2008 11:00:59 -0700, Ben Voigt [C++ MVP] <rbv@xxxxxxxxxxxxx> wrote:
I thought you were saying that return by reference isn't needed.
No. Well, personally I don't see it as being a big deal. In that sense, I don't really think it's needed.
But no, that's not what I was saying. I was just saying that as C# stands today, it doesn't really provide that functionality.
I'm championing the opposite, that pointers aren't good enough so we need
return by reference.
I agree that pointers aren't good enough to address the question. I don't really think it's strictly necessary to add return by reference.
IMHO it's a philosophical difference, and it's one that I think comes up between you and me on a regular basis. One of the reasons I love C# so much is its simplicity. It's true, there are lots of things you can do in a more "powerful" language like C++ that aren't exactly duplicated in C#. But IMHO you can always achieve basically the same results, and in a much simpler context.
Some engineers like complicated design, some like simple design. I'm in the latter camp, in that I find the simplicity leads to architectures that are easier to design correctly and reliably. IMHO, introducing a "return by reference" semantic would not be in keeping with the existing semantics in C# and would unnecessarily complicate the language.
You obviously disagree, as does the OP. But you are both free to use a different language, one that does support what you'd like to do. Why invest effort in messing up C# for those of us that appreciate its simplicity?
You say, make it a reference type. That's really the
problem, .NET forces you to choose between value and reference semantics in
the type declaration, which is a bad architecture. Maybe 99% of the time
value semantics are desired, placing the object inside its container is
desirable for locality of reference, and it doesn't need to be independently
garbage collected. Seems to me that demands a .NET value type. But now for
the 1% of uses which require return by reference, you're going to change the
behavior of every user of that type.
Well, I disagree with that perspective. There's a fundamental difference between value types and reference types in C#, and this difference is preserved by the current restriction in the language wrt return types, and would not be if methods could return value types "by reference". I disagree that it's bad architecture for the type itself to determine whether value or reference semantics are appropriate.
I'm not going to try to argue that it's _superior_ architecture, but I will vehemently disagree that it's de facto a bad choice for the language. It's simply a design choice, and a valid one at that. You may not like it, but there's no shortage of other languages to choose from in which you aren't so constrained.
[...]Yes. I don't see anything wrong with that statement. The Win32 API
is a specific API and doesn't take into account garbage collection at
all. In fact, the main reason we have IDisposable and finalizers is
that garbage collection and the Win32 API do not otherwise "get along
with each other".
That's "different", not a conflict.
If there was a conflict, .NET couldn't exist.
I guess that depends on whether you feel the word "conflict" implies lack of resolution. I don't. You seem to.
And, __makeref IS part of the language. It's not part of the international
standard though.
I have no idea what that means. If it's not part of the standard, how is it part of "the language"? I can write a C++ compiler to include whatever non-standard elements I want. Microsoft has in fact done so repeatedly. That doesn't mean those elements are part of "the language". They are just non-standard additions.
Pete
.
- References:
- Re: c# features
- From: Peter Duniho
- Re: c# features
- From: Jarlaxle
- Re: c# features
- From: Peter Duniho
- Re: c# features
- From: Ben Voigt [C++ MVP]
- Re: c# features
- From: Peter Duniho
- Re: c# features
- From: Ben Voigt [C++ MVP]
- Re: c# features
- From: Peter Duniho
- Re: c# features
- From: Ben Voigt [C++ MVP]
- Re: c# features
- From: Peter Duniho
- Re: c# features
- From: Ben Voigt [C++ MVP]
- Re: c# features
- Prev by Date: OOP problem: multiple inheritance througt interfaces?
- Next by Date: Re: Thread Debugging
- Previous by thread: Re: c# features
- Next by thread: Re: c# features
- Index(es):
Relevant Pages
|
Loading