digitalmars.D - The default can be used as a property is very bad design.
- Brian (30/30) Jan 24 2019 OH NO !
- Adam D. Ruppe (5/7) Jan 24 2019 This has nothing to do with property. It is just a local variable
- Neia Neutuladh (2/2) Jan 24 2019 As for this being very bad design, pretty much every programming languag...
OH NO ! sample code: ```D import std.stdio; struct Config { string test = "aaa"; string test2 = "bbb"; } Config config() { Config conf; return conf; } class Test { void func1() { string config; string testConfig = config().test; writeln(testConfig); } } ``` build error: ```shell osx:test zoujiaqing$ dmd config.d config.d(22): Error: function expected before (), not config of type string ```
Jan 24 2019
On Friday, 25 January 2019 at 02:09:29 UTC, Brian wrote:OH NO !This has nothing to do with property. It is just a local variable - those always take precedence over global ones. Use the module scope operator to use one outside; the leading dot:string testConfig = config().test;string testConfig = .config().test; // note the leading dot
Jan 24 2019
As for this being very bad design, pretty much every programming language with the concept of a local variable shares this trait.
Jan 24 2019