Re: Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
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: 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

Re: Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
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: 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

Re: Mixin Template Function Attributes

2016-01-20 Thread Marc Schütz via Digitalmars-d-learn
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 `}`.

Re: Mixin Template Function Attributes

2016-01-20 Thread Marc Schütz via Digitalmars-d-learn
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.dlan

Mixin Template Function Attributes

2016-01-20 Thread jmh530 via Digitalmars-d-learn
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

Re: Mixin template function

2013-02-14 Thread cal
On Thursday, 14 February 2013 at 07:40:58 UTC, Jacob Carlborg wrote: This is by design. Foo and A have different overload sets. Try: alias Foo.foo foo; http://dlang.org/template-mixin.html Search for: "Mixin Scope" and pay attention to: "Alias declarations can be used to overload together fun

Re: Mixin template function

2013-02-13 Thread Jacob Carlborg
On 2013-02-14 01:29, cal wrote: Should the following work? import std.traits; mixin template Foo() { void foo(T)(T t) if (isSomeString!T) {} } class A { void foo()(int i){} mixin Foo; } void main() { auto a = new A; a.foo("hello"); } Error: template hello.A.foo does

Re: Mixin template function

2013-02-13 Thread Jacob Carlborg
On 2013-02-14 06:49, cal wrote: And a related question: class A { void foo(int i){} void foo(Tuple!(int) i){} } class B: A { override void foo(int i){} } int main() { auto b = new B; b.foo(tuple(5)); } This fails to compile. Why can't B use A's tuple overload of foo

Re: Mixin template function

2013-02-13 Thread monarch_dodra
On Thursday, 14 February 2013 at 05:49:33 UTC, cal wrote: And a related question: class A { void foo(int i){} void foo(Tuple!(int) i){} } class B: A { override void foo(int i){} } int main() { auto b = new B; b.foo(tuple(5)); } This fails to compile. Why can't B use A's

Re: Mixin template function

2013-02-13 Thread monarch_dodra
On Thursday, 14 February 2013 at 00:29:51 UTC, cal wrote: Should the following work? import std.traits; mixin template Foo() { void foo(T)(T t) if (isSomeString!T) {} } class A { void foo()(int i){} mixin Foo; } void main() { auto a = new A; a.foo("hello"); } Error: templ

Re: Mixin template function

2013-02-13 Thread cal
And a related question: class A { void foo(int i){} void foo(Tuple!(int) i){} } class B: A { override void foo(int i){} } int main() { auto b = new B; b.foo(tuple(5)); } This fails to compile. Why can't B use A's tuple overload of foo()? If I do this: class B: A {

Mixin template function

2013-02-13 Thread cal
Should the following work? import std.traits; mixin template Foo() { void foo(T)(T t) if (isSomeString!T) {} } class A { void foo()(int i){} mixin Foo; } void main() { auto a = new A; a.foo("hello"); } Error: template hello.A.foo does not match any function template decla