Re: C# Language Proposal for 'out' Parameters

From: Bruno Jouhier [MVP] (bjouhier_at_club-internet.fr)
Date: 04/14/04


Date: Wed, 14 Apr 2004 21:13:10 +0200


> If the assignment isn't made because an exception has been thrown, I
> think that's fine - that's what copyout means (as I understand it) -
> not that every time the assignment is made, the property is written.

I agree, and I don't fully understand Daniel's point.

a call like
    Foo(inout expression) // copyin/copyout semantics
behaves "exactly" like:
    expression = Foo(expression)

and a call like
    Bar(out expression) // copyout semantics
behaves "exactly" like:
    expression = Bar()

We write this all the time, and we don't have any real issue with these
constructs. So, I don't see why copyin/copyout argument passing would create
a new problem (Daniel, I don't understand if your issue is on the caller or
callee's side but I don't see any real issue on the callee's side either).

On the other hand, I think that copyin/copyout would be slightly simpler to
explain than "ref" semantics and we would not get all these posts from
people who get confused between "passing by reference" and "passing the
reference" (fortunately Jon has a very good page on this one).

Bruno.



Relevant Pages

  • Re: Finding the instance reference of an object [long and probably boring]
    ... The only oddity in Python is that things you might not expect to be variables actually are. ... this implies that the corresponding parameter should become a reference to that reference value. ... You've just described passing an object reference by reference. ... I think we should simply address the root cause of that confusion, not try to redefine their understanding of how parameters are passed, and ALSO redefine what assignment means. ...
    (comp.lang.python)
  • Re: why cannot assign to function call
    ... reference to that array and passing the reference by value, ... The difference is whether an assignment to the formal parameter (within ...
    (comp.lang.python)
  • Re: By value or by reference?
    ... Here is the difference between pass by reference and pass by ... I find it simpler to explain as: the semantics of argument passing are ... _exactly_ identical to that of assignment to a barename; ... languages where "variables are boxes" to a language where "variables are ...
    (comp.lang.python)
  • Re: Why does this code work?
    ... call with no assignment ... A Command object is by reference always. ... an object by reference and passing a reference by value. ...
    (microsoft.public.dotnet.general)
  • Re: JavaScript knowledge test
    ... The assignment can produces a runtime error when the object being assigned to is a host object and it throws an exception when the assignment is made to an 'x' proeperty. ... on IE if no global 'x' variable is declared but an element exists in the DOM with the ID attribute "x" then IE creates an 'x' proeprty of the global object and assigns it a reference to the DOM element. ... The assigning of the returned inner function form that example to an intrinsic event property of a DOM node does result in the DOM node having an indirect reference to a JS object, but so long as the JS object does not then hold a reference to the DOM node the circle is not closed and no garbage collection issues follow. ...
    (comp.lang.javascript)