Re: mixin issue

2023-11-29 Thread Paul Backus via Digitalmars-d-learn
On Wednesday, 29 November 2023 at 13:31:14 UTC, DLearner wrote: ``` Error: found `End of File` when expecting `;` following statement ``` If an extra ; is added: ``` }(` ~ strStartPtr ~ `,` ~ strPLPtr ~ `);`; ``` it works but doesn't seem correct. This is an annoying limitation of the D

Re: mixin issue

2023-11-29 Thread Dennis via Digitalmars-d-learn
On Wednesday, 29 November 2023 at 13:31:14 UTC, DLearner wrote: it works but doesn't seem correct. You're mixing in an expression that creates an empty function and calls it. What do you want it to do?

mixin issue

2023-11-29 Thread DLearner via Digitalmars-d-learn
The code: ``` void main() { struct SB { char SBChrFld1; char SBChrFld2; int SBIntFld1; int SBIntFld2; } SB SBVar; SB* wkSBPtr; void* StartPtr1 = null; mixin(mxnDelMbr("StartPtr1", "wkSBPtr")); return; } string mxnDelMbr()(string strStartPt

Re: Strange Mixin issue

2014-03-05 Thread Ali Çehreli
On 03/05/2014 03:10 PM, Frustrated wrote: >> assert(s.Do(1, 2.5) == 3.5); > And this is exactly what I don't what! Sorry, I've completely misunderstood. :) > Do, in my case, is a ctfe used > only at compile time to make it easy to generate code. It's not needed > at runtime and does not be

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:33:25 UTC, Frustrated wrote: Maybe the problem isn't what I thought it was. I created a test case that works: import std.stdio, std.cstream; mixin template C() { alias A = typeof(this); mixin(B!(A)); } template B(T) { pragma(msg, T); e

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
Maybe the problem isn't what I thought it was. I created a test case that works: import std.stdio, std.cstream; mixin template C() { alias A = typeof(this); mixin(B!(A)); } template B(T) { pragma(msg, T); enum B() { return "string foo() { return `<"~T.stringof~">`; }";

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 23:04:06 UTC, Ali Çehreli wrote: On 03/05/2014 02:37 PM, Frustrated wrote: >> import std.typetuple; >> >> template fooImpl(T...) >> { >> static assert(is (T[0] == S));// <-- COOL! >> static assert(is (T[1] == int)); >> static assert(is (T[2] == doubl

Re: Strange Mixin issue

2014-03-05 Thread Ali Çehreli
On 03/05/2014 03:04 PM, Ali Çehreli wrote: template Do(T...) { mixin DoImpl!(TypeTuple!(typeof(this), T)); Actually, TypeTuple is not needed there: mixin DoImpl!(typeof(this), T); Ali

Re: Strange Mixin issue

2014-03-05 Thread Ali Çehreli
On 03/05/2014 02:37 PM, Frustrated wrote: >> import std.typetuple; >> >> template fooImpl(T...) >> { >> static assert(is (T[0] == S));// <-- COOL! >> static assert(is (T[1] == int)); >> static assert(is (T[2] == double)); >> } >> >> template foo(T...) >> { >> alias foo = fooIm

Re: Strange Mixin issue

2014-03-05 Thread Ali Çehreli
On 03/05/2014 01:30 PM, Frustrated wrote: I am trying to remove the unnecessary passing of the type of class to a template but can't seem to get it to work: see The code is the mixin(AbstractToInterface!(WindowsGui, iButton, WindowsButton, iBorder, WindowsBorder)); which I want to not

Re: Strange Mixin issue

2014-03-05 Thread Frustrated
On Wednesday, 5 March 2014 at 22:35:46 UTC, Ali Çehreli wrote: On 03/05/2014 01:30 PM, Frustrated wrote: I am trying to remove the unnecessary passing of the type of class to a template but can't seem to get it to work: see The code is the mixin(AbstractToInterface!(WindowsGui, iButto

Strange Mixin issue

2014-03-05 Thread Frustrated
I am trying to remove the unnecessary passing of the type of class to a template but can't seem to get it to work: see The code is the mixin(AbstractToInterface!(WindowsGui, iButton, WindowsButton, iBorder, WindowsBorder)); which I want to not have to specify WindowsGui. I've t

Re: Template Mixin issue

2009-01-30 Thread Christopher Wright
Christopher Wright wrote: Mike L. wrote: If the compiler can tell that B!(int) is a type, why can't it tell that it is a child class of A!(int) ? This is a bug. In template specializations, : means equality. In static if, : means convertibility. This is only with template specializations in

Re: Template Mixin issue

2009-01-30 Thread Christopher Wright
Mike L. wrote: If the compiler can tell that B!(int) is a type, why can't it tell that it is a child class of A!(int) ? This is a bug. In template specializations, : means equality. In static if, : means convertibility. So, you can use: template ADefaults(Type, AType) { static asser

Template Mixin issue

2009-01-29 Thread Mike L.
Hello, I was wondering why the following does not work: interface A(Type) { Type blah(); } template ADefaults(Type, AType : A!(Type)) { Type blah() { return Type.init; } } class B(Type) : A!(Type) { mixin ADefaults!(Type, B!(Type)); } void main()