Mixin helper help

2023-01-12 Thread John Chapman via Digitalmars-d-learn
I'm obviously doing something wrong, but don't quite understand. ```d mixin template helper() { mixin("writeln(12);"); } struct Foo { void opDispatch(string name)() { import std.stdio; mixin helper!(); //mixin("writeln(12);"); } } void main() { Foo.init.opDispatch!"bar"(); }

Re: Vibe.d serve files from filesystem

2023-01-12 Thread evilrat via Digitalmars-d-learn
On Wednesday, 11 January 2023 at 18:56:47 UTC, eXodiquas wrote: Hello everyone, I build a web tool that allows people to upload some files. Those files should not be public, so I copy them into a folder hidden away on the filesystem. But, I want an authenticated user to be able to look at the

Re: Mixin helper help

2023-01-12 Thread Hipreme via Digitalmars-d-learn
On Thursday, 12 January 2023 at 08:03:34 UTC, John Chapman wrote: I'm obviously doing something wrong, but don't quite understand. ```d mixin template helper() { mixin("writeln(12);"); } struct Foo { void opDispatch(string name)() { import std.stdio; mixin helper!(); //mixin("wr

Nested sibling classes

2023-01-12 Thread seany via Digitalmars-d-learn
Please Consider the code: import std.stdio; class a { public: this(){} ~this(){} class b { public: this.outer.c C = new this.outer.c(); this() { writel

Re: Nested sibling classes

2023-01-12 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 12 January 2023 at 17:05:04 UTC, seany wrote: How can I make it, that classes b and c can access each other, and create instances of each other freely? Thank you. Ignoring the typos you could try auto and static: ```d class a { //outer static class b { // inner 1 c C;

Re: Nested sibling classes

2023-01-12 Thread seany via Digitalmars-d-learn
On Thursday, 12 January 2023 at 17:41:39 UTC, Salih Dincer wrote: On Thursday, 12 January 2023 at 17:05:04 UTC, seany wrote: How can I make it, that classes b and c can access each other, and create instances of each other freely? Thank you. Ignoring the typos you could try auto and static:

Re: Nested sibling classes

2023-01-12 Thread Salih Dincer via Digitalmars-d-learn
On Thursday, 12 January 2023 at 17:46:45 UTC, seany wrote: Please, can you explain what role "static" plays here? Thank you again Of course, there are actually 2 paragraphs of information and examples [here]( https://dlang.org/spec/class.html#nested-context): Non-static nested classes work

Re: Nested sibling classes

2023-01-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On 1/12/23 12:05 PM, seany wrote: How can I make it, that classes b and c can access each other, and create instances of each other freely? Thank you. So to just point out something that wasn't discussed by Salih: When you declare a field of a class with an initializer, *that initializer i

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Salih Dincer via Digitalmars-d-learn
On Tuesday, 10 January 2023 at 01:22:33 UTC, H. S. Teoh wrote: Here's a challenge. Given an input year, for example, "2023", write a program that outputs (for the corresponding year): Now, I wrote a nested class using range and copying from Matheus' code. Of course not as comprehensive as [yo

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.23 23:22, monkyyy wrote: On Tuesday, 10 January 2023 at 19:10:09 UTC, Christian Köstlin wrote: On 10.01.23 01:17, Paul wrote: There is also https://exercism.org/tracks/d with some tasks for dlang. Kind regards, Christian Its all converted code; worthless I was not aware, that the qu

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Christian Köstlin via Digitalmars-d-learn
On 10.01.23 23:30, Paul wrote: On Tuesday, 10 January 2023 at 01:31:28 UTC, Ali Çehreli wrote: On 1/9/23 16:17, Paul wrote: > coding challenges Perhaps the following two?   https://rosettacode.org/   https://adventofcode.com/ Ali Excellent.  Thanks. For this years advent-of-code Steven S

Re: Coding Challenges - Dlang or Generic

2023-01-12 Thread Paul via Digitalmars-d-learn
On Thursday, 12 January 2023 at 20:28:26 UTC, Christian Köstlin wrote: For this years advent-of-code Steven Schveighoffer (https://github.com /schveiguy/adventofcode/tree/master/2022) has a complete set of dlang solutions. Kind regards, Christian Very helpful. Thanks Christian.

(Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread thebluepandabear via Digitalmars-d-learn
(Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` inside another module, since `ObjDerived` can still access the members

Re: (Noob question) Should subclasses be defined in separate modules?

2023-01-12 Thread Mike Parker via Digitalmars-d-learn
On Friday, 13 January 2023 at 05:17:59 UTC, thebluepandabear wrote: (Sorry if this is a duplicate.) If I have the following code inside of a module: ```D class Obj { private { string name = "Hi"; } } class ObjDerived : Obj { } ``` Is it best practice to define `ObjDerived` in