D Lang'99 & Its future
Martin Tschierschke
mt at smartdolphin.de
Wed Feb 9 12:24:32 UTC 2022
On Wednesday, 9 February 2022 at 10:21:33 UTC, bauss wrote:
> On Wednesday, 9 February 2022 at 08:38:00 UTC, Martin
> Tschierschke wrote:
>> On Tuesday, 8 February 2022 at 18:28:21 UTC, H. S. Teoh wrote:
>>
>>>
>>> In latest dmd git HEAD, you need to annotate this function
>>> with `return`, because it escapes a reference to `this`. :-)
>>>
>> Sorry, I am to stupid, where do you have to "annotate return"?
>
> I believe it would be like this:
>
> ```d
> ref string toString() return
> {
> return bits;
> }
> ```
Thank you I tried it, at the https://tour.dlang.org/ rdmd
Playground and
got a casting error, so I changed ```string``` to ```char[8]```
and it worked:
no return needed: (?)
```
import std.stdio;
void main()
{
enum Dlang99 = 4026728633831507;
union Magic
{
long data;
char[8] bits;
char[8] toString()
{
return bits;
}
}
auto magic = Magic(Dlang99<<10|'D');
magic.writefln!"..::%s::..";
}
```
More information about the Digitalmars-d
mailing list