<div dir="ltr"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 26 Aug 2024 at 02:31, Steven Schveighoffer via Digitalmars-d <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sunday, 25 August 2024 at 05:07:43 UTC, Manu wrote:<br>
> This is a really old drum to beat on... but maybe we need to <br>
> start pounding<br>
> it again.<br>
><br>
> It's not strictly this simple though; I think there's a lot of <br>
> work up-front. We don't really even know what a tuple is, or <br>
> even what "kinds" of things the language can express...<br>
><br>
> Like, there's more than types and values. There's symbol <br>
> aliases, which may or may not carry an instance reference with <br>
> them, declaration aliases, which may carry names and properties <br>
> like storage class, there's sometimes expression aliases, <br>
> there's potentially attributes, and heaps of other stuff that <br>
> exists outside the language; like storage class, which doesn't <br>
> seem to have any presence in the language at all; it's queried <br>
> with a __traits and comically tells you those facts as string <br>
> literals! I think this space might be the heart and soul of D's <br>
> foundational issues, and as such, it's excruciatingly hard to <br>
> make corrections.<br>
><br>
> Like, from my example above, what even IS `s.tupleof`? It's <br>
> some kind of<br>
> list of what kind of thing? Direct symbol references to members <br>
> of a live<br>
> instance?<br>
> If s.tupleof can populate a list with that kind of thing, why <br>
> doesn't this<br>
> work:<br>
><br>
> struct S<br>
> {<br>
> int x, y;<br>
> }<br>
><br>
> struct T<br>
> {<br>
> S s;<br>
> int i;<br>
><br>
> alias a = i; // works<br>
> alias b = s.x; // Doesn't work? Why?<br>
> }<br>
<br>
All good points I think. AliasSeq and aliases in general have <br>
always been a sore spot in D meta.<br></blockquote><div><br></div><div>Indeed, and despite that, it's also quite likely that it is simultaneously also D's single most important and noteworthy feature! Above literally everything else by a country mile.<br></div><div>I think every meaningful advantage that D brings to the table essentially stems from `alias` in some form, or this general realm of D's meta.<br></div><div><br></div><div>I think it's really important to try and make a strong case that this stuff is of the most critical importance. There's fault lines and fractures all over the place; this category of issues should be addressed with a laser focus and ruthless murder... and it should have happened 15 years ago.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> It seems like s.tupleof presents that there are semantics in <br>
> the language to express this sort of thing, but it's not clear <br>
> what to call that.<br>
><br>
> Likewise in my example above:<br>
><br>
> alias a = s.tupleof; // this can hold the list of references, <br>
> which seem to<br>
> carry around their instance reference with them<br>
> alias b = s.tupleof[0]; // this emits a surprising error <br>
> message:<br>
><br>
> error : alias `b` cannot alias an expression `AliasSeq!(s.x, <br>
> s.y)[0]`<br>
><br>
> So, that 'list' I mention; does this error message imply that <br>
> this list given by `tupleof` is an AliasSeq? What exactly IS an <br>
> AliasSeq? What is the actual set of things that it can hold?<br>
><br>
> If tupleof is an AliasSeq, then what's going on here:<br>
><br>
> alias c = AliasSeq!(s.tupleof);<br>
> alias d = c[0]; // the error is now gone??<br>
<br>
At first, I was thinking WTF is this? How can this work?<br>
<br>
But the answer is, it doesn't.<br>
<br>
if you try to *use* `d` you will get an error, because there is <br>
no instance -- you ended up aliasing the symbol without the <br>
instance.<br></blockquote><div><br></div><div>Oh nice catch...</div><div>But that just leads to the question; what's with `b` then?</div><div>Why did `b` emit the error eagerly at the assignment, but `d` decided to take a lazy approach as you say?<br></div><div><br></div><div>What I really want to know though; why do these aliases drop the instance? That's just a bug right?</div><div>There's no reason you would want that behaviour, and it's obvious that an alias+instance reference <i>can</i> be carried by the AST, because it's there before it's unceremoniously dropped basically whenever you touch it.<br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> I think a good indication that this whole space is profoundly <br>
> troubled when classic patterns like this emerge:<br>
><br>
> template T(alias X) { use X } // oh no you don't, alias is <br>
> very<br>
> opinionated! you'll need this instead:<br>
> template T(X...) if (X.length == 1) { use X[0] }<br>
<br>
This is no longer needed, so at least there is a bit of progress.<br></blockquote><div><br></div><div>It's not?</div><div>I just had to write an instance of this hack yesterday, for the same traditional reasons as ever... :/</div><div>What changed? I'll take another look at it.</div></div></div>