digitalmars.D.learn - Issue with 2.071: Regression or valid error?
- Andre (28/29) Apr 06 2016 Hi,
- Craig Dillabaugh (5/34) Apr 06 2016 Not so up to date on D's OOP stuff, but don't you want create()
- Craig Dillabaugh (4/9) Apr 06 2016 clip
- Daniel Kozak via Digitalmars-d-learn (5/34) Apr 06 2016 This should not compile. Cat cant access create because it is private. O...
- Andre (4/11) Apr 06 2016 Thanks for the answers.
- Steven Schveighoffer (11/38) Apr 07 2016 Wow, totally agree with you. Compiler shouldn't make you jump through
- 9il (4/17) Apr 07 2016 Why this is a bug? private methods are not virtual, are they?
- Daniel Kozak (2/25) Apr 08 2016 No they are not virtual, so this is not a bug.
- Rene Zwanenburg (7/26) Apr 08 2016 I disagree, virtuality has nothing to do with this. After all,
- Steven Schveighoffer (8/28) Apr 08 2016 A Cat is an Animal. The compiler knows this. The 'a' module has access
- Daniel Kozak via Digitalmars-d-learn (2/31) Apr 08 2016 Yes ou are right, I see it now :), thanks.
- Steven Schveighoffer (4/5) Apr 08 2016 I filed it for you:
Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards André module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -------------- module b; import a; class Cat: Animal {}; compile withrdmd a b
Apr 06 2016
On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote:Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards André module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -------------- module b; import a; class Cat: Animal {}; compile withNot so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create().rdmd a b
Apr 06 2016
On Wednesday, 6 April 2016 at 19:01:58 UTC, Craig Dillabaugh wrote:On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote:clipNot so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a base class, which is what you are doing with cat.create().You CAN'T typically access a private ...
Apr 06 2016
This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal u=C5=BEivatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn puremagic.com>:Hi, With 2.071 following coding does not compile anymore and somehow I feel i=tshould compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards Andr=C3=A9 module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -------------- module b; import a; class Cat: Animal {}; compile withrdmd a b
Apr 06 2016
On Wednesday, 6 April 2016 at 19:22:44 UTC, Daniel Kozak wrote:This should not compile. Cat cant access create because it is private. Ok it can access it but only if you move cat into same module as animal Dne 6. 4. 2016 17:16 napsal uživatel "Andre via Digitalmars-d-learn" < digitalmars-d-learn puremagic.com>:Thanks for the answers. Kind regards André
Apr 06 2016
On 4/6/16 11:10 AM, Andre wrote:Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within the class Animal for cat. Is the error message "no property create for type 'b.cat'" valid or not? Kind regards André module a; import b; class Animal { private void create() {} void foo(Cat cat) { cat.create(); // >> no property create for type 'b.cat' } } void main() {} -------------- module b; import a; class Cat: Animal {};Just FYI, you don't need a semicolon there.compile withWow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened. -Steverdmd a b
Apr 07 2016
On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote:On 4/6/16 11:10 AM, Andre wrote:Why this is a bug? private methods are not virtual, are they? --Ilya[...]Just FYI, you don't need a semicolon there.Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened. -Steve[...]
Apr 07 2016
On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote:On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote:No they are not virtual, so this is not a bug.On 4/6/16 11:10 AM, Andre wrote:Why this is a bug? private methods are not virtual, are they? --Ilya[...]Just FYI, you don't need a semicolon there.Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened. -Steve[...]
Apr 08 2016
On Friday, 8 April 2016 at 08:26:11 UTC, Daniel Kozak wrote:On Friday, 8 April 2016 at 06:08:38 UTC, 9il wrote:I disagree, virtuality has nothing to do with this. After all, moving Cat to the same module as Animal, or making create() public final will make the code compile. Private symbols can (only) be accessed from the module where they are defined, so anything in the animal module should be able to call create() on a Cat just fine.On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote:No they are not virtual, so this is not a bug.Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened. -SteveWhy this is a bug? private methods are not virtual, are they? --Ilya
Apr 08 2016
On 4/8/16 2:08 AM, 9il wrote:On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote:A Cat is an Animal. The compiler knows this. The 'a' module has access to Animal private methods. This isn't a virtual call, but a call to a base class member. Those are allowed. How can you think this is not a bug? Would you think it was a bug if create was a final function instead of private? This is exactly the same thing. -SteveOn 4/6/16 11:10 AM, Andre wrote:Why this is a bug? private methods are not virtual, are they? --Ilya[...]Just FYI, you don't need a semicolon there.Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened.[...]
Apr 08 2016
Dne 8.4.2016 v 14:56 Steven Schveighoffer via Digitalmars-d-learn napsal(a):On 4/8/16 2:08 AM, 9il wrote:Yes ou are right, I see it now :), thanks.On Thursday, 7 April 2016 at 15:55:16 UTC, Steven Schveighoffer wrote:A Cat is an Animal. The compiler knows this. The 'a' module has access to Animal private methods. This isn't a virtual call, but a call to a base class member. Those are allowed. How can you think this is not a bug? Would you think it was a bug if create was a final function instead of private? This is exactly the same thing. -SteveOn 4/6/16 11:10 AM, Andre wrote:Why this is a bug? private methods are not virtual, are they? --Ilya[...]Just FYI, you don't need a semicolon there.Wow, totally agree with you. Compiler shouldn't make you jump through this hoop: void foo(Cat cat) { Animal a = cat; a.create(); } Please file a bug report, not sure why this happened.[...]
Apr 08 2016
On 4/7/16 11:55 AM, Steven Schveighoffer wrote:Please file a bug report, not sure why this happened.I filed it for you: https://issues.dlang.org/show_bug.cgi?id=15897 -Steve
Apr 08 2016