Re: Defining classes with cyclic dependencies

2024-03-17 Thread Per Nordlöw via Digitalmars-d-learn

On Sunday, 17 March 2024 at 20:38:16 UTC, Per Nordlöw wrote:

I was surprised that the compiler cannot compile

```d
class A { B b; }
class B { C c; }
class C { D d; }
class D { A a; }
```

. Shouldn't it?


Ahh, nevermind. I defined these inside a unittest scope so that's 
why it failed. Defining them at module scope works just fine.


Defining classes with cyclic dependencies

2024-03-17 Thread Per Nordlöw via Digitalmars-d-learn

I was surprised that the compiler cannot compile

```d
class A { B b; }
class B { C c; }
class C { D d; }
class D { A a; }
```

. Shouldn't it?


Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-17 Thread Adam D Ruppe via Digitalmars-d-learn

On Saturday, 16 March 2024 at 20:34:57 UTC, Inkrementator wrote:
Nice. Btw I vaguely remember you also wrote about how and why 
to reduce the usage string mixins, with some real example of 
alternative techniques you used


go to the main page: http://dpldocs.info/this-week-in-d/Blog.html 
and use ctrl+f and hope i said it in the summary lol


but the two that pop up there are:

http://dpldocs.info/this-week-in-d/Blog.Posted_2022_12_26.html#more-mixin-techniques

and

https://forum.dlang.org/post/fbcltjuysmjrxmebe...@forum.dlang.org


The general rule is to try to use the local name inside the 
string instead of concatenating its result, and remember the 
built in compiler-tuple - which is what __traits(getAttributes) 
and the parameters reflection and other things - can be used 
directly in a lot of places, you can very often substitute one of 
those for a value and it will put it in for you. I encourage you 
to experiment with plugging these things directly in at the use 
site and seeing what happens before falling back to strings.


fyi don't really follow this forum anymore, you got a bit lucky 
that i popped in for the dconf online link, so i might not see 
any further replies to this.