Thread overview
'in', 'out', returning references?
Apr 28, 2004
skelly
Apr 28, 2004
J Anderson
Apr 28, 2004
Ivan Senji
Apr 28, 2004
Andy Friesen
Apr 28, 2004
Andy Friesen
May 08, 2004
Matthew
May 08, 2004
Ivan Senji
April 28, 2004
I really like the use of "in" and "out" in argument lists, but because then the purpose is documented in the code, but is there a way to return a reference to an object besides using a pointer?

(Note, sometimes it is a builtin type, sometimes not.)

Sam
April 28, 2004
skelly@vatproducts.com wrote:

>I really like the use of "in" and "out" in argument lists, but
>because then the purpose is documented in the code, but is there
>a way to return a reference to an object besides using a pointer?
>
>(Note, sometimes it is a builtin type, sometimes not.)
>
>Sam
>  
>
If your talking about a primitive type (int, float ect..) or a struct, then without using out, and without using a pointer, no.  If your talking about class objects, then these are already references (unlike C++ but like java).

-- 
-Anderson: http://badmama.com.au/~anderson/
April 28, 2004
<skelly@vatproducts.com> wrote in message news:c6og8o$68h$1@digitaldaemon.com...
> I really like the use of "in" and "out" in argument lists, but because then the purpose is documented in the code, but is there a way to return a reference to an object besides using a pointer?

I also wish there was a way but there isn't :(


>
> (Note, sometimes it is a builtin type, sometimes not.)
>
> Sam


April 28, 2004
skelly@vatproducts.com wrote:
> I really like the use of "in" and "out" in argument lists, but
> because then the purpose is documented in the code, but is there
> a way to return a reference to an object besides using a pointer?

I'm not sure if this is what you're after, but it's perfectly legal to say 'Object* o'.  It behaves like a pointer-pointer would in C++.

 -- andy
April 28, 2004
Andy Friesen wrote:

> skelly@vatproducts.com wrote:
> 
>> I really like the use of "in" and "out" in argument lists, but
>> because then the purpose is documented in the code, but is there
>> a way to return a reference to an object *besides using a pointer?*
> 
> 
> I'm not sure if this is what you're after, but it's perfectly legal to say 'Object* o'.  It behaves like a pointer-pointer would in C++.

.... whups.  Need more coffee.

 -- andy
May 08, 2004
Is it possible to return a struct which wraps a reference?

Doh! No. Structs do not have ctors/dtors.

Maybe that's another argument for it?

<skelly@vatproducts.com> wrote in message news:c6og8o$68h$1@digitaldaemon.com...
> I really like the use of "in" and "out" in argument lists, but because then the purpose is documented in the code, but is there a way to return a reference to an object besides using a pointer?
>
> (Note, sometimes it is a builtin type, sometimes not.)
>
> Sam


May 08, 2004
"Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:c7hcc0$2878$1@digitaldaemon.com...
> Is it possible to return a struct which wraps a reference?

To do this i wrote a class that wraps a value returned, but the problem
is that the returned variable can only be accesed by property.
I have something like

ref!(int) func()
{
    static int x;
    return new ref!(int)(x);
}
...
func().value=5;

> Doh! No. Structs do not have ctors/dtors.

But constructor can be simulated with opCall.
I don't undestand how you mean a struct wraping a reference?

> Maybe that's another argument for it?
>
> <skelly@vatproducts.com> wrote in message
news:c6og8o$68h$1@digitaldaemon.com...
> > I really like the use of "in" and "out" in argument lists, but because then the purpose is documented in the code, but is there a way to return a reference to an object besides using a pointer?
> >
> > (Note, sometimes it is a builtin type, sometimes not.)
> >
> > Sam
>
>