digitalmars.D.learn - Mixin Template Function Attributes
- jmh530 (30/30) Jan 20 2016 I was thinking about using mixin templates to put some
- Marc =?UTF-8?B?U2Now7x0eg==?= (4/6) Jan 20 2016 It's not a bug. The `@attribute:` syntax applies to all following
- Marc =?UTF-8?B?U2Now7x0eg==?= (4/6) Jan 20 2016 I believe, however, that it _is_ a bug that the imported symbols
I was thinking about using mixin templates to put some module-level default information in a single file so that it doesn't clutter up other files. It works for imports, but it doesn't seem to propagate for function attributes. module_default.d ------------------- module module_default; mixin template module_default() { import std.traits : functionAttributes; import std.stdio : writeln; safe: } app.d ------------------- import module_default; mixin module_default; int foo(int x) { return x; } void main() { writeln(functionAttributes!foo); } Compiled with dmd app.d module_default.d on Windows 7 64bit. The output is system, when I would expect it to be safe. I'm not sure if this is how the behavior is supposed to be or if it is a bug.
Jan 20 2016
On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote:I'm not sure if this is how the behavior is supposed to be or if it is a bug.It's not a bug. The ` attribute:` syntax applies to all following declarations _inside the current scope_, i.e. until your mixin templates closing `}`.
Jan 20 2016
On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote:I'm not sure if this is how the behavior is supposed to be or if it is a bug.I believe, however, that it _is_ a bug that the imported symbols are visible outside the template. Most likely related to the infamous https://issues.dlang.org/show_bug.cgi?id=314
Jan 20 2016
On Wednesday, 20 January 2016 at 19:19:04 UTC, Marc Schütz wrote:On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote:Thanks. The fact that one worked and the other didn't was what I found weird.I'm not sure if this is how the behavior is supposed to be or if it is a bug.I believe, however, that it _is_ a bug that the imported symbols are visible outside the template. Most likely related to the infamous https://issues.dlang.org/show_bug.cgi?id=314
Jan 20 2016
On Wednesday, 20 January 2016 at 19:48:04 UTC, jmh530 wrote:On Wednesday, 20 January 2016 at 19:19:04 UTC, Marc Schütz wrote:It looks like this issue covers it https://issues.dlang.org/show_bug.cgi?id=12735 It appears that there is a pull request in the works to fix the behavior.On Wednesday, 20 January 2016 at 16:37:31 UTC, jmh530 wrote:Thanks. The fact that one worked and the other didn't was what I found weird.I'm not sure if this is how the behavior is supposed to be or if it is a bug.I believe, however, that it _is_ a bug that the imported symbols are visible outside the template. Most likely related to the infamous https://issues.dlang.org/show_bug.cgi?id=314
Jan 20 2016