digitalmars.D.bugs - [Issue 10815] New: Allow access of a symbol in a template instance if instantiator module has access to the symbol
- d-bugmail puremagic.com (68/68) Aug 13 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10815
- d-bugmail puremagic.com (14/14) Aug 13 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10815
- d-bugmail puremagic.com (7/7) Aug 13 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10815
http://d.puremagic.com/issues/show_bug.cgi?id=10815 Summary: Allow access of a symbol in a template instance if instantiator module has access to the symbol Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 05:13:21 PDT --- Currently the compiler disallows the following: ----- module test; import std.algorithm; private int foo(int input) { return input; } package int bar(int input) { return input; } void main() { map!foo([1, 2, 3]); map!bar([1, 2, 3]); } ----- C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(410): Error: function test.foo is not accessible from module algorithm C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(410): Error: function test.bar is not accessible from module algorithm The 'test' module explicitly passed a function that this module has access to, which should effectively give access of this function symbol to the instantiated template. I propose we allow the instantiated template to get access to the passed symbol if it's passed via an alias symbol, and if the module that instantiates the template has access to this symbol. Note that it is already possible to pass private functions via a pointer: ----- module test; import bar; private void func() { } void main() { call(&func); } ----- ----- module bar; void call(void function() func) { func(); } ----- This compiles. But with the relaxed access rule so should this (which currently doesn't compile): ----- module test; import bar; private void func() { } void main() { call!func(); } ----- ----- module bar; void call(alias func)() { func(); } ----- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 13 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10815 Dicebot <public dicebot.lv> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |public dicebot.lv I have always thought it is intentional: "TemplateInstantances are always performed in the scope of where the TemplateDeclaration is declared, with the addition of the template parameters being declared as aliases for their deduced types." (http://dlang.org/template.html) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 13 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10815 11:43:44 PDT --- Well it may be intentional, but it makes many Phobos functions unusable with internal library routines. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 13 2013