Re: Ref local variables?

2012-01-09 Thread Steven Schveighoffer
On Sun, 08 Jan 2012 12:54:13 -0500, Ben Davis ent...@cantab.net wrote: Hi, Is there a reason 'ref' is disallowed for local variables? I want to write something like: MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; My actual case is more

Re: Ref local variables?

2012-01-09 Thread bearophile
Steven Schveighoffer: With new = syntax (in git head), this would probably be: @property ref tile = map[y*w+x]; That's not currently supported: http://d.puremagic.com/issues/show_bug.cgi?id=7176 Bye, bearophile

Re: Ref local variables?

2012-01-09 Thread Steven Schveighoffer
On Mon, 09 Jan 2012 09:27:06 -0500, bearophile bearophileh...@lycos.com wrote: Steven Schveighoffer: With new = syntax (in git head), this would probably be: @property ref tile = map[y*w+x]; That's not currently supported: http://d.puremagic.com/issues/show_bug.cgi?id=7176 The given

Ref local variables?

2012-01-08 Thread Ben Davis
Hi, Is there a reason 'ref' is disallowed for local variables? I want to write something like: MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; My actual case is more complicated, so inlining the expression everywhere would be messy. I

Re: Ref local variables?

2012-01-08 Thread Trass3r
MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; MapTile* tile = map[y*w+x];

Re: Ref local variables?

2012-01-08 Thread Trass3r
Sorry, didn't read the rest. ^^

Re: Ref local variables?

2012-01-08 Thread simendsjo
On 08.01.2012 18:54, Ben Davis wrote: Hi, Is there a reason 'ref' is disallowed for local variables? I want to write something like: MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; My actual case is more complicated, so inlining the

Re: Ref local variables?

2012-01-08 Thread Ben Davis
I also meant to say: 80x25? Epic :D On 08/01/2012 20:25, Ben Davis wrote: There are two things going on in your example: 1. Use of 'auto' where I'm currently having to write 'MapTile*' and wanted to write 'ref MapTile'. It will infer 'MapTile*'. Or, if you forget the , then it will infer

Re: Ref local variables?

2012-01-08 Thread Ben Davis
There are two things going on in your example: 1. Use of 'auto' where I'm currently having to write 'MapTile*' and wanted to write 'ref MapTile'. It will infer 'MapTile*'. Or, if you forget the , then it will infer 'MapTile' and do the copy that I want to avoid. So it might be slightly more

Re: Ref local variables?

2012-01-08 Thread Simen Kjærås
On Sun, 08 Jan 2012 18:54:13 +0100, Ben Davis ent...@cantab.net wrote: Hi, Is there a reason 'ref' is disallowed for local variables? I want to write something like: MapTile[] map; // It's a struct ref MapTile tile=map[y*w+x]; tile.id=something; tile.isWall=true; My actual case is more