digitalmars.D - Oh, no UFCS for member functions
- =?UTF-8?B?THXDrXM=?= Marques (15/15) Mar 29 2016 Too bad this doesn't work:
- Anonymouse (5/20) Mar 29 2016 By design. I don't remember the rationale, though.
- =?UTF-8?B?THXDrXM=?= Marques (4/7) Mar 29 2016 Cool, I was not aware of that workaround. Also, I wonder if this
Too bad this doesn't work:
struct Player
{
MapTile[] playerMap; // partial private knowledge of map
Location destination;
auto tile(Location loc)
{
return playerMap[loc];
}
void foo()
{
if(destination.tile.hasMonster)
...
}
}
Mar 29 2016
On Tuesday, 29 March 2016 at 14:56:53 UTC, Luís Marques wrote:
Too bad this doesn't work:
struct Player
{
MapTile[] playerMap; // partial private knowledge of map
Location destination;
auto tile(Location loc)
{
return playerMap[loc];
}
void foo()
{
if(destination.tile.hasMonster)
...
}
}
By design. I don't remember the rationale, though.
The ugly workaround if you really don't want to reorganise things
(and/or use the tile function directly) is to make a top-level
alias tile = Player.tile;
Mar 29 2016
On Tuesday, 29 March 2016 at 15:08:05 UTC, Anonymouse wrote:The ugly workaround if you really don't want to reorganise things (and/or use the tile function directly) is to make a top-level alias tile = Player.tile;Cool, I was not aware of that workaround. Also, I wonder if this workaround doesn't argue somewhat against the rationale for not having member-function UFCS, whatever it was.
Mar 29 2016








=?UTF-8?B?THXDrXM=?= Marques <luis luismarques.eu>