Multiple alias this failed workaround...obscure error message

2014-06-11 Thread matovitch via Digitalmars-d-learn
I was looking for a workaround to multiple alias this (or opImplicitCast) the following trick doesn't work (why shouldn't it ?). The error message is quite obscure to me. import std.stdio; class A(Derived) { alias cast(ref Derived)(this).x this; } class B : A!B { float x; } class C

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
Sent: Wednesday, June 11, 2014 at 8:07 PM From: matovitch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com To: digitalmars-d-learn@puremagic.com Subject: Multiple alias this failed workaround...obscure error message I was looking for a workaround to multiple alias

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 18:07:44 UTC, matovitch wrote: source/app.d(5): Error: basic type expected, not cast source/app.d(5): Error: no identifier for declarator int source/app.d(5): Error: semicolon expected to close alias declaration source/app.d(5): Error: Declaration expected, not

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread matovitch via Digitalmars-d-learn
On Wednesday, 11 June 2014 at 20:53:21 UTC, Jonathan M Davis via Digitalmars-d-learn wrote: I don't believe that it's legal to use a cast in an alias declaration, and that's certainly what the error seems to be indicating. Also, using ref in a cast is definitely illegal regardless of where

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread matovitch via Digitalmars-d-learn
If I quote de documentation : Any casting of a class reference to a derived class reference is done with a runtime check to make sure it really is a downcast. null is the result if it isn't. Note: This is equivalent to the behavior of the dynamic_cast operator in C++. I explicitly kept

Re: Multiple alias this failed workaround...obscure error message

2014-06-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wed, 11 Jun 2014 23:01:31 + matovitch via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: About alias working with identifier but not with (runtime) expression. Alias should work with compile time expression like map!(x=2*x) right ? So a static cast should work isn't it ?