Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 31, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 Marcelo Silva Nascimento Mancini <msnmancini@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msnmancini@hotmail.com -- |
August 01, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 --- Comment #1 from anonymous4 <dfj1esp02@sneakemail.com> --- The return type is wrong. -- |
August 08, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 anonymous4 <dfj1esp02@sneakemail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |INVALID OS|Windows |All -- |
August 08, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 Marcelo Silva Nascimento Mancini <msnmancini@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- -- |
August 08, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 --- Comment #2 from Marcelo Silva Nascimento Mancini <msnmancini@hotmail.com> --- Have you even tested the code? -- |
August 09, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |razvan.nitu1305@gmail.com --- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> --- (In reply to Marcelo Silva Nascimento Mancini from comment #0) > This trivial code fails to compile with the error message: `onlineapp.Test2.mxString!(oops).mxString` need `this` to access member `mxString` > > ```d > class Test2 > { > string oops; > mixin(mxString!(oops)); > } > enum mxString(alias c)() > { > return ""; > } > ``` > > This should compile as there is no dependent usage on "this". Plus, the message is obviously wrong as there is no member named `mxString`. > > A real use case for that is: > ```d > enum mxString(alias c)() > { > return typeof(c).stringof~" "~c.stringof~c.stringof~";"; > } > ``` > Which does not depends on "this", as some code like `mxString!(typeof(oops), > oops.stringof)` would work. > > Mixin template does not have this limitation, so, I believe a normal function should not too. I don't really understand what you are trying to achieve here? mixin templates are used to insert declarations in a scope. If you want to mixin a function, why not declare mxString as: ``` class Test2 { string oops; mixin mxTempl!(oops); } mixin template mxTempl(alias c) { enum mxString() { return ""; } } ``` This is an enhancement request at best. However, I don't really see the point of this code. Why would you want to insert a publicly declared template in the scope of an aggregate? Why not just call the function template when it is needed with the appropriate template parameter? -- |
August 09, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 --- Comment #4 from Marcelo Silva Nascimento Mancini <msnmancini@hotmail.com> --- (In reply to RazvanN from comment #3) > (In reply to Marcelo Silva Nascimento Mancini from comment #0) > > This trivial code fails to compile with the error message: `onlineapp.Test2.mxString!(oops).mxString` need `this` to access member `mxString` > > > > ```d > > class Test2 > > { > > string oops; > > mixin(mxString!(oops)); > > } > > enum mxString(alias c)() > > { > > return ""; > > } > > ``` > > > > This should compile as there is no dependent usage on "this". Plus, the message is obviously wrong as there is no member named `mxString`. > > > > A real use case for that is: > > ```d > > enum mxString(alias c)() > > { > > return typeof(c).stringof~" "~c.stringof~c.stringof~";"; > > } > > ``` > > Which does not depends on "this", as some code like `mxString!(typeof(oops), > > oops.stringof)` would work. > > > > Mixin template does not have this limitation, so, I believe a normal function should not too. > > I don't really understand what you are trying to achieve here? mixin templates are used to insert declarations in a scope. If you want to mixin a function, why not declare mxString as: > > ``` > class Test2 > { > string oops; > mixin mxTempl!(oops); > > } > > mixin template mxTempl(alias c) > { > enum mxString() > { > return ""; > } > } > ``` > > This is an enhancement request at best. However, I don't really see the point of this code. Why would you want to insert a publicly declared template in the scope of an aggregate? Why not just call the function template when it is needed with the appropriate template parameter? Because I don't want to deal with mixin template overloads. When they are executed, its overloads becomes inside them, so, I'm doing a code for using string mixin instead. If I wish to generate the overloads using mixin template, I must do `alias overload = mixed.overload;` for each function defined inside it. If I wish to iterate through its overloads and alias to them, I must do a named mixin template, which will actually be inserted on its namespace. This can be solved by doing another mixin template which actually executes a static foreach over members from the named mixin template and generate the alias declarations. This is literally fighting the language. -- |
August 10, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 Boris Carvajal <boris2.9@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |boris2.9@gmail.com --- Comment #5 from Boris Carvajal <boris2.9@gmail.com> --- I think this is a known bug, there are some reports in the past of similar compiler behavior. Related issues 17435, 18969, 20077, 22497. Put 'static' in the definition as a workaround. static enum mxString(alias c)() { return ""; } -- |
December 17, 2022 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
December 13 [Issue 23278] Can't pass alias member to a function | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23278 --- Comment #6 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20137 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation