Re: Another spinoza challenge



"spinoza1111" <spinoza1111@xxxxxxxxx> wrote in message news:39ea5c77-5a58-443f-a103-a3101c46253c@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 25, 1:09 pm, Richard Heathfield <r...@xxxxxxxxxxxxxxx> wrote:
Phil Carmody said:



> Kenneth Brody <kenbr...@xxxxxxxxxxx> writes:
<snip>

>> It appears that some people can't grasp the fact that passing a
>> variable by reference, and passing the address of a variable by
>> value
>> are not the same thing. (Yes, you can achieve the effect of
>> changing the caller's variable's value by doing pointer-by-value,
>> but that doesn't make them the same thing.)

> It appears that some people can't grasp the fact that one can
> effect pass by reference by passing variables by address.

Only by torturing the concept of pass by reference beyond its yield
point. If passing the address of a variable were equivalent to
passing by reference, then the following program would print 42:

#include <stdio.h>

void byref(int *p)
{
p = 42; /* bug - p was *not* passed by reference. */

}

This might be a better "representation" of references:
______________________________________________________
#define ref *
#define toref &


void inc(int ref self)
{
int ref r1 = self;
int prev = ref r1;

ref self = 5;
assert(ref r1 == 5);

ref r1 = 6;
assert(ref self == 6);

ref self = prev + 1;
}


void foo()
{
int v = 0;

inc(toref v);
assert(v == 1);
}
______________________________________________________




lol.

.



Relevant Pages

  • Re: Why are get/set properties useful?
    ... passing reference objects to functions, ... ref PricingConditionTable, ... add/remove accessors around them, which is, after all, pretty much the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Pass by reference vs Pass by Value (is data aliasing a problem in C#?)
    ... keyword ref is able to do, using passing-ref-by-value, rather than ... using keyword 'ref' and passing-ref-by-reference, ... How would you implement int.TryParsewithout passing by reference? ... Usually you don't need to pass by reference, and so that's why usually passing by reference isn't done. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how to use List Class in Base class?
    ... If I don't pass by ref and pass the instance of the class to ... Reference types are already a reference to an object allocated ... Passing a reference type as is (i.e. ... you'd be passing a pointer to a pointer to an instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using ref
    ... but that's just a side-effect of what "by value" really is: making a copy of the original argument and passing that to the method. ... The reference _is_ the data. ... But more importantly, C++ distinguishes between passing a pointer by value, and passing a pointer by reference. ... But that's only when you use the "ref" or "out" keyword. ...
    (microsoft.public.dotnet.languages.csharp)
  • passing by ref for value type and storing this in a member...
    ... I would like to hear peoples thoughts on passing a value type by reference ... A a = new A(ref passbyref); ... still false as class A simply took a copy of ref. ... In a nutshell I want the 'passbyref' reference to be updated in A.B ...
    (microsoft.public.dotnet.languages.csharp)