Properties: a.b.c = 3

Kagamin spam at here.lot
Wed Jul 29 00:30:35 PDT 2009


Walter Bright Wrote:

> The issue is what if b is a property, returns a temporary object, and 
> that temp's .c field is uselessly set to 3?
> 
> It's a classic problem with properties that are implemented as functions.

Does this problem pertain to properties?
Look at this:

void main()
{
  int a=3;
}

Is "a" assigned usefully or uselessly? And what compiler says about it? And how did you determine that your example is useless? Did you check for destructors, invariants, copy constructors?

And do your question imply that functions are allowed to return temporaries while properties aren't?

And what's the difference if c is field or property?



More information about the Digitalmars-d mailing list