Re: Returning a struct by reference

2009-03-21 Thread BCS
Hello Simon, If I add a getter-property that returns the field by value, the following instruction "object.position.x = 12;" won't modify the position of the object, but will only modify the returned copy of the position, right? That's actually why I'd like to have a getter that returns the fie

Re: Returning a struct by reference

2009-03-21 Thread grauzone
Simon TRENY wrote: Daniel Keep Wrote: Simon TRENY wrote: Ok, but then, what if I'd like to make the variable "read-only"? i.e. preventing the user from writing things like this: myObject.position = pos2; So... you're rejecting a solution on the basis that it prevents you from doing the exa

Re: Returning a struct by reference

2009-03-21 Thread Sergey Gromov
Sat, 21 Mar 2009 09:55:13 -0400, Simon TRENY wrote: >//This syntax is not working >public ref Position position() { > return m_position; >} D2 supports this. D1 won't, ever. I think.

Re: Returning a struct by reference

2009-03-21 Thread Simon TRENY
grauzone Wrote: > Simon TRENY wrote: > > grauzone Wrote: > > > >> Simon TRENY wrote: > >>> Hi there! > >>> > >>> I'm quite new at D and I'm still just playing with it, but there is a > >>> thing that I find currently missing. Sometimes, I'd like to be able to > >>> return a struct by reference

Re: Returning a struct by reference

2009-03-21 Thread Simon TRENY
Daniel Keep Wrote: > > > Simon TRENY wrote: > > Ok, but then, what if I'd like to make the variable "read-only"? i.e. > > preventing the user from writing things like this: > > myObject.position = pos2; > > > > So... you're rejecting a solution on the basis that it prevents you from > doing t

Re: Returning a struct by reference

2009-03-21 Thread grauzone
Simon TRENY wrote: grauzone Wrote: Simon TRENY wrote: Hi there! I'm quite new at D and I'm still just playing with it, but there is a thing that I find currently missing. Sometimes, I'd like to be able to return a struct by reference and not by value. For example, in the following example:

Re: Returning a struct by reference

2009-03-21 Thread Simon TRENY
grauzone Wrote: > Simon TRENY wrote: > > Hi there! > > > > I'm quite new at D and I'm still just playing with it, but there is a thing > > that I find currently missing. Sometimes, I'd like to be able to return a > > struct by reference and not by value. For example, in the following example: >

Re: Returning a struct by reference

2009-03-21 Thread Daniel Keep
Simon TRENY wrote: > Ok, but then, what if I'd like to make the variable "read-only"? i.e. > preventing the user from writing things like this: > myObject.position = pos2; > So... you're rejecting a solution on the basis that it prevents you from doing the exact opposite of what you want to do

Re: Returning a struct by reference

2009-03-21 Thread grauzone
Simon TRENY wrote: Hi there! I'm quite new at D and I'm still just playing with it, but there is a thing that I find currently missing. Sometimes, I'd like to be able to return a struct by reference and not by value. For example, in the following example: struct Position { float x; floa

Returning a struct by reference

2009-03-21 Thread Simon TRENY
Hi there! I'm quite new at D and I'm still just playing with it, but there is a thing that I find currently missing. Sometimes, I'd like to be able to return a struct by reference and not by value. For example, in the following example: struct Position { float x; float y; } class Object