Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 24, 2009 [Issue 2889] New: Alias this properties don't overload with non-alias this properties. | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=2889 Summary: Alias this properties don't overload with non-alias this properties. Product: D Version: 2.029 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: dsimcha@yahoo.com struct ArrayWrapper { uint[] arr; alias arr this; void length(uint l) {}; } void main() { ArrayWrapper aw; auto len = aw.length; } Errors: C:\home\dsimcha\bin\test.d(10): Error: function test.ArrayWrapper.length (uint l) does not match parameter types () C:\home\dsimcha\bin\test.d(10): Error: expected 1 function arguments, not 0 C:\home\dsimcha\bin\test.d(10): Error: variable test.main.len voids have no value C:\home\dsimcha\bin\test.d(10): Error: expression aw.length() is void and has no value If I comment out the length property in the ArrayWrapper struct, length gets forwarded properly to arr and the code compiles. -- |
August 14, 2011 [Issue 2889] Alias this properties don't overload with non-alias this properties. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2889 Trass3r <mrmocool@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mrmocool@gmx.de Platform|x86 |All OS/Version|Windows |All --- Comment #1 from Trass3r <mrmocool@gmx.de> 2011-08-14 15:01:37 PDT --- This is also critical for proper simulation of struct inheritance. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 14, 2011 [Issue 2889] Alias this properties don't overload with non-alias this properties. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2889 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |k.hara.pg@gmail.com --- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2011-08-14 15:30:58 PDT --- I think this is a language design, not a bug. In normal class inheritance, derived class method doesn't overload with base class methods that have same names. class Array // the synonym of uint[] { size_t length(){ return 0; } void length(size_t n){ } // built-in length property (getter and setter) } class ArrayWrapper : Array { void length(uint l) {} // length overrides Array.length, not overloads } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 03, 2011 [Issue 2889] Alias this properties don't overload with non-alias this properties. | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=2889 Trass3r <mrmocool@gmx.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #3 from Trass3r <mrmocool@gmx.de> 2011-11-03 04:04:51 PDT --- Yeah, you're right. See http://www.digitalmars.com/d/2.0/hijack.html for the rationale. Overloading is done explicitly with alias just like you use using in C++ for this purpose. Unfortunately you can't alias arr.length length; in this particular case though: Error: alias test.ArrayWrapper.length cannot alias an expression arr.length The only option is to use a small function that wraps arr.length I guess. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation