Status on DIP 1040?

Tejas notrealemail at gmail.com
Tue Aug 3 12:53:41 UTC 2021


On Tuesday, 3 August 2021 at 11:51:38 UTC, Paul Backus wrote:
> On Tuesday, 3 August 2021 at 08:29:15 UTC, Tejas wrote:
>>
>> I know they're not real(see my original post's 2nd last 
>> sentence), but I was working out how to transpile C++ and 
>> without being able to represent rvalue refs, it's going to be 
>> impossible.
>> How can you hope to accurately represent ```t&&``` without 
>> rvalue refs?
>
> Perhaps look at how rvalue references are implemented 
> under-the-hood in existing C++-to-native-code compilers, and 
> use a similar technique in your C++-to-D compiler? After all, 
> there is no such thing as an "rvalue reference" in assembly 
> either.
>
> Of course, this means you will have to do some semantic 
> analysis on the C++ code to figure out when a parameter is 
> being passed by rvalue reference, and translate it accordingly.

Sorry, but that sounds like saying implementing a generational 
garbage collector should be possible since assembly doesn't have 
a notion of "garbage collection".

Even zombinedev said above that _construct_ ```t&&``` itself is 
not supported by the type system of D.

If what you're saying was possible then Walter and Manu needn't 
have bothered with ```preview=rvaluerefparam``` since D compiles 
to native code, which can represent all constructs.

Another example: template constraints vs concepts. No matter 
what, we simply cannot transform constraints in such a way that 
we won't have to write ```if``` in the very first line of 
template definition. Sure, we might be able to hide it behind an 
alias, or function, at attribute or whatever; but you **will** have 
to write that ```if```, because D simply doesn't support writing 
template constraints in another way(and mixins don't allow that 
syntax-changing "monkey business"(I don't disagree that the label 
is wrong, btw)). Atlia went the attributes way and made this:
  https://github.com/atilaneves/concepts
But you still require to put the ```if``` in your template.

Lastly, I urge you as well to see this post that I linked 
previously

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

Even Mathias is agreeing that there is no way to represent this 
(that he knows of).

I hope I'm not coming off as snarky. I too don't like talking 
about this again and again like a broken record but I also don't 
think there's a way to represent them without a language change. 
I know about 
[this](http://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it), but that's like saying we don't need @nogc exceptions because [this](http://p0nce.github.io/d-idioms/#Throwing-despite-@nogc) exists.


More information about the Digitalmars-d mailing list