arrays = pointers?

P

Peter Duniho

Peter said:
The garbage collector actually does neither of what you claim that it
has to. ;)
I have not once claimed that the garbage collector does anything in
particular. [...]

Ok, then let me quoute you:

"In the .NET paradigm, the collector has to either scan the entire
collection of data for each object it wants to move, or it has to
maintain some sort of hash table or other fast-access data structure in
which it stores (at least temporarily) all of the current references to
each given object (which is essentially the "reference reference table"
method anyway)."

There you claim that there is only two possible ways for the garbage
collector to work.

Yes. The garbage collector must have some means of identifying references
to update. Either it looks for them each time, or has some data structure
that provides that information without requiring it to look for them each
time. This is a logical necessity. There are only two possibilities:
determine the references each time, or determine them ahead of time.
Making the trivially true statement that the garbage collector must do one
or the other doesn't even come close to making a statement about how the
garbage collector actually works.

That said, you are clearly on a single-minded quest to find fault in
whatever I write. I see no need to continue this course of discussion
with you, as it's completely unproductive. It seems only to serve to feed
whatever need it is you have, and frankly that's not among my list of
things to achieve in this lifetime.

Pete
 
R

Ravichandran J.V.

Well, you know wrong then. Pointers can still be used in C# as below:

using System;
class a
{
unsafe public void calc(int x,int *p){
*p=x*x;
}
public static void Main()
{
int n=0;
unsafe{
int *p=&n;
a a1=new a();
a1.calc(12,p);
Console.WriteLine(n);
}
}
}


with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Z

Zytan

Well, you know wrong then. Pointers can still be used in C# as below:

Yes, we've already established that.

The purpose of the question was to inquire what references really were
(to help my understanding of them). As I suspected, they are pointers
internally (that can be changed around internally when their objects
are moved to new location by the GC while the app is frozen, so it's
not a good idea to use their literal value and assume it'll be
constant, but that's not what I intended to do).

So, the question wasn't about if C# had pointers itself that can be
used as pointers like C, but to get an idea of what a reference is
really all about. It's easier to understand them when you know what's
under the hood.

Zytan
 
R

Ravichandran J.V.

I am sure this must have come across your attention already. The pointer
used in the unsafe context would be assigned to the unmanaged memory
heap. Let me elaborate only on specific points as and when you come up
with them as otherwise, it may just turn out to be repeating things that
you may already know of.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Z

Zytan

J.V., thanks for the help, but this issue of mine has been resolved.
I understand it all, now, thanks to everyone for their help.

Zytan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top