@property needed or not needed?
Jacob Carlborg
doob at me.com
Tue Nov 20 04:44:43 PST 2012
On 2012-11-19 19:02, Adam D. Ruppe wrote:
> On Monday, 19 November 2012 at 15:01:36 UTC, Andrei Alexandrescu wrote:
>> Would you please start a DIP with a paste of this idea?
>
> here it is:
> http://www.prowiki.org/wiki4d/wiki.cgi?LanguageDevel/DIPs/DIP21
>
> I tried to implement this a while ago and hit some pain after some early
> success. The pain was trying to get assignments to work without breaking
> other cases like returning ref.
>
> My plan was to make any reference to a @property change to a CallExp or
> whatever. But if you do that and it is on the left hand side of an
> assignment, you do the wrong thing.
>
> foo = foo + 1;
>
> should generally become:
>
> foo(foo() + 1);
>
> but if there isn't a setter, we should leave it as foo() = foo() + 1;
> and finding the setter is a bit of a pain. Then, of course, we ideally
> want foo += 1 to work too..
It would be really nice if we could implement property rewriting in the
compiler.
> Maybe someone who knows the compiler better than me will make it look
> easy though.
Should this be allowed for functions that isn't marked with @property:
foo = 3;
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list