realbasic-nug
[Top] [All Lists]

Re: ByRef with properties (was: Error I don't understand)

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: ByRef with properties (was: Error I don't understand)
From: Mars Saxman <mars at realsoftware dot com>
Date: Mon, 04 Oct 2004 10:48:42 -0700
Delivered-to: realbasic-nug at lists dot realsoftware dot com
larsjensen at rcn dot com wrote:

> then I get an error, it's straightforward for me to convert it to this:
> 
> dim i as integer = myObject.myProperty
> MyMethod(i)
> myObject.myProperty = i
> 
> What's stopping the compiler from doing that allocation of temporary
> storage, and doing the assignment on return?

It would introduce a side-effect. You must assume that neither MyMethod nor
any of the methods it could potentially call could ever care about the fact
that myObject.myProperty does not *actually* equal i until after MyMethod
returns. You can make this assumption, since you wrote the code and know
what it expects; the compiler does not know what you intended and must stick
to the face value of the expression.

Besides, it would make the ByRef rules more confusing. Right now it's
simple: "no expressions, simple variables only".

Mars Saxman
REAL Software

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>