digitalmars.D.bugs - [Issue 3452] New: Can't alias member functions such that the object name is implicitly stored in the alias
- d-bugmail puremagic.com (30/30) Oct 29 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3452
- d-bugmail puremagic.com (10/10) Feb 08 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3452
- d-bugmail puremagic.com (22/22) Aug 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3452
- d-bugmail puremagic.com (17/32) Aug 06 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3452
- d-bugmail puremagic.com (15/19) Aug 07 2013 http://d.puremagic.com/issues/show_bug.cgi?id=3452
http://d.puremagic.com/issues/show_bug.cgi?id=3452 Summary: Can't alias member functions such that the object name is implicitly stored in the alias Product: D Version: 2.035 Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: dsimcha yahoo.com struct Foo { void bar() {} void baz() {} } void doStuff(Foo foo) { alias foo.bar fun; fun(); // Error: need 'this' to access member bar } I can't think of any reason why this shouldn't work. foo.bar is a compile-time symbol for the member function Foo.bar() on the instance foo. Once I alias foo.bar to fun, calling fun() should be equivalent to calling foo.bar(). Even if there's some language legalese reason why this shouldn't work according to the spec, it's still a reasonable enhancement request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3452 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |samukha voliacable.com 15:36:42 PST --- *** Issue 7828 has been marked as a duplicate of this issue. *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 08 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3452 Dicebot <public dicebot.lv> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |public dicebot.lv Another application is template alias parameter: string boo(alias T)() { return T.stringof; } struct A { int field; } pragma(msg, boo!(A.field)()); currently this fails with "Error: need 'this' for 'boo' of type 'nothrow safe string()'" which does not make sense because compile-time usage of symbol "A.field" does not require "this" pointer. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3452 Maxim Fomin <maxim maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim maxim-fomin.ru ---struct Foo { void bar() {} void baz() {} } void doStuff(Foo foo) { alias foo.bar fun; fun(); // Error: need 'this' to access member bar }Actually error message is reasonable for the same reason as Foo.bar requires this pointer. The root of the issue is that alias does not capture local variable in this context - it captures only type name. The code above is essentially alias Foo.bar fun and since bar() is nonstatic the code doesn't compile.I can't think of any reason why this shouldn't work. foo.bar is a compile-time symbol for the member function Foo.bar() on the instance foo. Once I alias foo.bar to fun, calling fun() should be equivalent to calling foo.bar().Because of underspecification many view things different to what compiler does.Even if there's some language legalese reason why this shouldn't work according to the spec, it's still a reasonable enhancement request.Yes, but this isn't a minor enhancement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 06 2013
http://d.puremagic.com/issues/show_bug.cgi?id=3452The root of the issue is that alias does not capture local variable in this context - it captures only type name. The code above is essentially alias Foo.bar fun and since bar() is nonstatic the code doesn't compile.There is a big issue with `alias` specification because of no clear definition what is captured. Current documentation simply describes behavior of reference implementation in various cases which is rather inconsistent on its own (as far as I am aware, there is no even common alias handling in dmd). Now my understanding of the `alias` concept is simple - it should capture symbols, be it type symbol or variable symbol or anonymous lambda literal symbol. But I think you are right - cleaning this is worth separate DIP, plenty of corner cases will arise. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 07 2013