Puzzled
monkyyy
crazymonkyyy at gmail.com
Tue Dec 12 19:50:25 UTC 2023
On Tuesday, 12 December 2023 at 19:02:11 UTC, Don Allen wrote:
>
> I'm probably missing something here, perhaps some important
> cases where the behavior I'm seeing *does* make sense. I'd be
> interested in the comments of those who know D (and perhaps
> C++) better than I do.
Your imagining aliases as words rather than references to
definitions
As far as I know, aliases are optimized to work with "overload
sets"
```d
void foo(int);
void foo(bool);
template bar(alias A){}
bar!foo;
```
A is now all foo's, foo's need to exist, and foo mostly pretends
to stop knowing where it comes from
do:
```d
struct Foo {
int bar;
int baz;
}
void bletch(alias field)(int x) {
field = x;
writeln("%d", s.field);
}
int main(string[] args)
{
Foo s;
bletch!(s.bar);
bletch!(s.baz);
return 0;
}
```
More information about the Digitalmars-d
mailing list