Consider the following example:
```
struct A
{
auto a(int _a)
{
return this._a = _a;
}
int _a = 0;
}
void main()
{
static assert(!__traits(compiles, { A()._a = 2; }));
static assert(__traits(compiles, { A().a(2); }));
}
```
(https://run.dlang.io/is/GkmpA8)
Why i
On Saturday, 13 June 2020 at 11:26:58 UTC, Johannes Loher wrote:
Why is it a compile error to set `_a` directly but calling `a`
just works fine?
If we prevent modifying members of rvalues directly, I would
also expect calling non-const member functions of rvalues to be
prevented.
1) Constr
On Saturday, 13 June 2020 at 12:47:31 UTC, Stanislav Blinov wrote:
[...]
The temporary exists until the end of full expression, or until
the end of enclosing statement. It is simply not an lvalue for
the caller, but it certainly exists, and so its interface must
function.
So public data memb