digitalmars.D.learn - property
- Fyodor Ustinov (4/4) Nov 09 2015 Hi!
- Alex Parrill (17/21) Nov 09 2015 Check out the following code:
- Fyodor Ustinov (14/30) Nov 09 2015 But the compiler is lying!
- Gary Willoughby (3/9) Nov 10 2015 The feature is not being removed. Only the @property attribute
- Jonathan M Davis via Digitalmars-d-learn (16/27) Nov 10 2015 All that's being removed at this point is the -property switch which
- Kagamin (2/2) Nov 10 2015 It was intended for stricter properties. See
Hi! Why do need " proprety" if everything works without it? WBR, Fyodor.
Nov 09 2015
On Monday, 9 November 2015 at 21:56:22 UTC, Fyodor Ustinov wrote:Hi! Why do need " proprety" if everything works without it? WBR, Fyodor.Check out the following code: struct Test { int foo() { return 2; } int bar() property { return 2; } } pragma(msg, typeof(Test.foo)); // Prints int(); i.e. a zero-argument function that returns an int pragma(msg, typeof(Test.bar)); // Prints int; i.e. a plain int AFAIK when property was introduced, it was expected that after a deprecation period, calling non-property functions without parenthesis would be invalid, but I don't think that panned out. It's still good for documentation.
Nov 09 2015
On Monday, 9 November 2015 at 22:06:22 UTC, Alex Parrill wrote:Check out the following code: struct Test { int foo() { return 2; } int bar() property { return 2; } } pragma(msg, typeof(Test.foo)); // Prints int(); i.e. a zero-argument function that returns an int pragma(msg, typeof(Test.bar)); // Prints int; i.e. a plain intBut the compiler is lying! void main() { auto a = Test(); auto aa = &a.bar; // if type of a.bar is int writeln(*aa); // why: Error: can only * a pointer, not a 'int delegate() property' }AFAIK when property was introduced, it was expected that after a deprecation period, calling non-property functions without parenthesis would be invalid, but I don't think that panned out. It's still good for documentation.If this feature will be removed, it will be very lacking code, like: writeln = "Hello, world!"; :) WBR, Fyodor.
Nov 09 2015
On Monday, 9 November 2015 at 22:42:16 UTC, Fyodor Ustinov wrote:If this feature will be removed, it will be very lacking code, like: writeln = "Hello, world!"; :) WBR, Fyodor.The feature is not being removed. Only the property attribute and compiler check is being removed.
Nov 10 2015
On Tuesday, November 10, 2015 09:53:42 Gary Willoughby via Digitalmars-d-learn wrote:On Monday, 9 November 2015 at 22:42:16 UTC, Fyodor Ustinov wrote:All that's being removed at this point is the -property switch which enforced that non- property functions be called with parens (since once UFCS was introduced, everyone hated having to provide empty parens for function calls that already had parens for template arguments). It's still up for discussion what we're going to do in terms of enforcing that property functions get called without parens or whether we're going to require property for the setter syntax, though we almost have to make it so that if an property function returns a callable (e.g. delegate) that the parens call that callable, otherwise you really can't have property functions that return callables. For now, property is _mostly_ for documentation purposes (though it does affect a few things like typeof). There are multiple DIPs on the topic (e.g. http://wiki.dlang.org/DIP23 ), but until one is accepted, we don't know for sure what's going to happen with property. - Jonathan M DavisIf this feature will be removed, it will be very lacking code, like: writeln = "Hello, world!"; :) WBR, Fyodor.The feature is not being removed. Only the property attribute and compiler check is being removed.
Nov 10 2015
It was intended for stricter properties. See http://dlang.org/changelog/2.069.0.html#property-switch-deprecated Last iteration on it was http://wiki.dlang.org/DIP23
Nov 10 2015