opApply Magic Function Body Transformation

2025-07-27 Thread Mike Shah via Digitalmars-d-learn
I'm preparing a video to teach opApply, and I think I'm still kind of unsure on how opApply works in regards to the compiler transformation. It's one of those features I understand how to use, but I'd like a bit of a deeper understanding before I teach it -- to admittingly really know what I am

extern(C) on var decl is confusing

2025-07-27 Thread user1234 via Digitalmars-d-learn
That is confusing, e.g ``` extern(C) int r; int main() { return r; } ``` works. But what is likely more intended here is ``` extern int r; int main() { return r; } ``` which leads, this time, to the expected linker error.

Re: Class-Inheritancing Error

2025-07-27 Thread user1234 via Digitalmars-d-learn
On Sunday, 27 July 2025 at 15:14:03 UTC, H. S. Teoh wrote: On Sun, Jul 27, 2025 at 11:08:33AM +, David T. Oxygen via Digitalmars-d-learn wrote: I wrote a piece of code like this: ```d class Person{ string name; this(string name){this.name=name;} } class Someone:Person{

Re: Class-Inheritancing Error

2025-07-27 Thread H. S. Teoh via Digitalmars-d-learn
On Sun, Jul 27, 2025 at 11:08:33AM +, David T. Oxygen via Digitalmars-d-learn wrote: > I wrote a piece of code like this: > > ```d > class Person{ > string name; > this(string name){this.name=name;} > } > class Someone:Person{ > alias super this; > } > void main(){ > S

Re: Inherited constructor

2025-07-27 Thread Luna Nielsen via Digitalmars-d-learn
On Friday, 25 July 2025 at 03:57:34 UTC, Andy Valencia wrote: On Friday, 25 July 2025 at 02:40:35 UTC, H. S. Teoh wrote: In D, constructors are not inherited, so yes, unfortunately you have to write a forwarding ctor that passes the arguments along to the base class. My OO worldview goes bac

Re: How do I pass a variables as data with gtkd signals ?

2025-07-27 Thread huangyy via Digitalmars-d-learn
On Friday, 25 July 2025 at 19:21:07 UTC, Dejan Lekic wrote: On Friday, 25 July 2025 at 16:44:13 UTC, huangyy wrote: I want to write a small program with gtkd. I need to use Signals.connectData to transfer an int type parameter to the callback function. I don't know how to write it. I hope some

Class-Inheritancing Error

2025-07-27 Thread David T. Oxygen via Digitalmars-d-learn
I wrote a piece of code like this: ```d class Person{ string name; this(string name){this.name=name;} } class Someone:Person{ alias super this; } void main(){ Someone x=new Someone("Bob"); } ``` And then,I got a Error-Message: ``` ab.d(6): Error: variable name expe