Re: Transparent cast from class to member pointer?

2019-04-14 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-04-14 20:01:27 +, diniz said: Le 14/04/2019 à 20:03, Robert M. Münch via Digitalmars-d-learn a écrit : struct IM; struct C {  IM *impl; }; int cInit(C* self); class I { C handler; this(){cInit(&handler);} } Is there a simple way that I can use handler without the address

Re: Finding Super class from Derived Class at compile time

2019-04-14 Thread Ali Çehreli via Digitalmars-d-learn
On 04/14/2019 10:06 PM, LeqxLeqx wrote: Hello! I have a question regarding attempting to access the super class of a derived class at compile time. BaseClassesTuple and friends: https://dlang.org/phobos/std_traits.html Ali

Finding Super class from Derived Class at compile time

2019-04-14 Thread LeqxLeqx via Digitalmars-d-learn
Hello! I have a question regarding attempting to access the super class of a derived class at compile time. Specifically, if I have: class A { } class B : A { } void func(T)() { /+ find super-class of T +/ } int main () { func!B; /+ func would find A

Re: I really don't understand DUB

2019-04-14 Thread Andre Pany via Digitalmars-d-learn
On Sunday, 14 April 2019 at 19:46:41 UTC, Ron Tarrant wrote: On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote: [...] Just so you know who I am and what my experience is: I've only been using D for a few months and so far, I've only dabbled in dub. I used to write a blog for PHP-GTK

Re: Transparent cast from class to member pointer?

2019-04-14 Thread diniz via Digitalmars-d-learn
Le 14/04/2019 à 20:03, Robert M. Münch via Digitalmars-d-learn a écrit : struct IM; struct C {  IM *impl; }; int cInit(C* self); class I { C handler; this(){cInit(&handler);} } Is there a simple way that I can use handler without the address-of operator and automatically get *impl

Re: I really don't understand DUB

2019-04-14 Thread Ron Tarrant via Digitalmars-d-learn
On Monday, 8 April 2019 at 19:54:28 UTC, WhatMeWorry wrote: I've been trying to troubleshoot a DUB issue for two days now and I've come to the conclusion, I don't really understand DUB and I'm tired of muddling through. Just so you know who I am and what my experience is: I've only been using

Transparent cast from class to member pointer?

2019-04-14 Thread Robert M. Münch via Digitalmars-d-learn
struct IM; struct C { IM *impl; }; int cInit(C* self); class I { C handler; this(){cInit(&handler);} } Is there a simple way that I can use handler without the address-of operator and automatically get *impl? Something like: class I { C handler; this(){cIn

Re: How to mixin finction name?

2019-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 April 2019 at 17:33:51 UTC, Adam D. Ruppe wrote: That will expand to: I'm sorry, I skipped a step here. The compiler doesn't look into the mixin string until after it calls mixin, so technically it goes: static foreach -> mixin("void print" ~ 'A' ~ "(int a) { writeln(

Re: How to mixin finction name?

2019-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 April 2019 at 15:13:37 UTC, Johannes Loher wrote: At first I was very confused that this example even worked. Why does `ch` get expanded in the call to writeln? It is part of the mixed in string, so why does the string not simply include "writeln(ch, ...)" on every iteration? T

Re: How to mixin finction name?

2019-04-14 Thread Johannes Loher via Digitalmars-d-learn
Am 14.04.19 um 15:22 schrieb Adam D. Ruppe: > [...] > Though, I'd point out the mixin code doesn't have to be too ugly. > Consider this: > > void main() > { >     enum letters = ['A', 'B', 'C']; > >     static foreach(ch; letters) >     { >     mixin(q{ >     void print}~ch~q{(int i) { >

Re: How to mixin finction name?

2019-04-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 April 2019 at 12:00:38 UTC, Andrey wrote: I want to mixin only name - not the full function code. You can't. Best you can do is write the function separately and then mixin an alias for it with the other name. void main() { enum letters = ['A', 'B', 'C']; // normal imp

Re: How to mixin finction name?

2019-04-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 April 2019 at 12:00:38 UTC, Andrey wrote: On Sunday, 14 April 2019 at 11:44:16 UTC, Boris Carvajal wrote: On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote: I want to mixin only name - not the full function code. I think you can't do a partial statement in a mixin. But this

Re: How to mixin finction name?

2019-04-14 Thread Andrey via Digitalmars-d-learn
On Sunday, 14 April 2019 at 11:44:16 UTC, Boris Carvajal wrote: On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote: Create some function in loop and use it. But I don't know how to mixin names? import std.stdio; void main() { enum letters = ['A', 'B', 'C']; static foreach(ch; le

Re: How to mixin finction name?

2019-04-14 Thread Boris Carvajal via Digitalmars-d-learn
On Sunday, 14 April 2019 at 10:07:30 UTC, Andrey wrote: Create some function in loop and use it. But I don't know how to mixin names? import std.stdio; void main() { enum letters = ['A', 'B', 'C']; static foreach(ch; letters) { mixin("void print" ~ ch ~ "(uint i) { writ

How to mixin finction name?

2019-04-14 Thread Andrey via Digitalmars-d-learn
Hi, I want to do something like this: void main() { enum letters = ['A', 'B', 'C']; static foreach(ch; letter) { void mixin("print" ~ ch)(uint i) { writeln(ch, " - ", i); } } printB(6); } Create some function in loop and use it. But

Re: gtkDcoding Blog Post # 26 - Menu Basics

2019-04-14 Thread number via Digitalmars-d-learn
On Saturday, 13 April 2019 at 12:42:36 UTC, Ron Tarrant wrote: On Saturday, 13 April 2019 at 09:49:47 UTC, number wrote: On Saturday, 13 April 2019 at 00:25:21 UTC, Ron Tarrant wrote: I'm asking because ... the messagebox sized itself to the shorter text in the content area. They said it's an O