On Wednesday, 23 October 2024 at 18:39:15 UTC, H. S. Teoh wrote:
The key here is to understand that "alias" != "macro".
Re-reading this topic today and indeed that was the missing
piece. I was sure that alias is just a compile-time string
replacement akin to C macros, just with some niceties
On Wednesday, 23 October 2024 at 15:25:48 UTC, Salih Dincer wrote:
If it were me, I would equip my type with aliases like below.
But for some reason I don't understand, the enum Numbers works,
while the enum Test which is of type string doesn't!
I figured out why it wasn't working. It turns
On Wednesday, 23 October 2024 at 17:18:47 UTC, Anton Pastukhov
wrote:
On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus
wrote:
You can't use an `alias` to refer to a member variable like
this. When you write
alias myAlias = myStruct.test;
...it is silently rewritten by the com
On Wednesday, 23 October 2024 at 18:05:15 UTC, monkyyy wrote:
Its intended and probably the right decision, but good luck
finding relivent docs.
What's the motivation behind it? For me, it looks like a weird
edge case but I'm just probably missing something here
On Wednesday, 23 October 2024 at 19:10:05 UTC, Jonathan M Davis
wrote:
On Wednesday, October 23, 2024 11:18:47 AM MDT Anton Pastukhov
via Digitalmars-d-learn wrote:
On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus
wrote:
> On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
> w
On Wed, Oct 23, 2024 at 06:10:07PM +, Anton Pastukhov via
Digitalmars-d-learn wrote:
> On Wednesday, 23 October 2024 at 18:05:15 UTC, monkyyy wrote:
> >
> > Its intended and probably the right decision, but good luck finding
> > relivent docs.
>
> What's the motivation behind it? For me, it
On Wednesday, 23 October 2024 at 18:39:15 UTC, H. S. Teoh wrote:
On Wed, Oct 23, 2024 at 06:10:07PM +, Anton Pastukhov via
Digitalmars-d-learn wrote:
On Wednesday, 23 October 2024 at 18:05:15 UTC, monkyyy wrote:
>
> Its intended and probably the right decision, but good luck
> finding reli
On Wednesday, October 23, 2024 11:18:47 AM MDT Anton Pastukhov via
Digitalmars-d-learn wrote:
> On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus wrote:
> > On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
> > wrote:
> >
> > You can't use an `alias` to refer to a member variable
On Wednesday, 23 October 2024 at 17:18:47 UTC, Anton Pastukhov
wrote:
On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus
wrote:
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
wrote:
You can't use an `alias` to refer to a member variable like
this. When you write
al
On Wednesday, 23 October 2024 at 14:50:44 UTC, Paul Backus wrote:
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
wrote:
You can't use an `alias` to refer to a member variable like
this. When you write
alias myAlias = myStruct.test;
...it is silently rewritten by the compile
On Wednesday, October 23, 2024 9:06:46 AM MDT Salih Dincer via Digitalmars-d-
learn wrote:
> The code also compiles like this. In this case, can we say that
> there are 3 solutions or are static and enum actually the same
> thing?
static and enum are not the same thing.
An enum has no memory loca
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
I'm struggling with this code. Why `countUntil` won't work with
aliases?
```d
import std.traits : EnumMembers;
import std.algorithm : countUntil;
enum Test: string
{
One = "one",
Two = "two",
Three = "three"
}
```
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus wrote:
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
There are two possible solutions to this. One is to make
`MyStruct.test` a `static` variable:
```d
// Solution #1
struct MyStruct {
static Test test = T
On Wednesday, 23 October 2024 at 13:00:15 UTC, Anton Pastukhov
wrote:
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus
wrote:
snip
Thanks, that's a good catch. `alias myAlias = MyStruct.test` is
really just a typo, I meant `alias myAlias = myStruct.test`,
so I actually have an i
On Wednesday, 23 October 2024 at 12:46:24 UTC, Paul Backus wrote:
snip
Thanks, that's a good catch. `alias myAlias = MyStruct.test` is
really just a typo, I meant `alias myAlias = myStruct.test`, so
I actually have an instance. It's still not compiling
On Wednesday, 23 October 2024 at 12:32:09 UTC, Anton Pastukhov
wrote:
I'm struggling with this code. Why `countUntil` won't work with
aliases?
```
import std.traits : EnumMembers;
import std.algorithm : countUntil;
enum Test: string {
One = "one",
Two = "two",
Three = "three"
}
str
16 matches
Mail list logo