Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
April 28, 2004 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to skelly | 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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to skelly | <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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to skelly | 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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | 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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to skelly | 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 Re: 'in', 'out', returning references? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | "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 > > |
Copyright © 1999-2021 by the D Language Foundation