Jump to page: 1 2
Thread overview
D Lang'99 & Its future
Feb 08, 2022
Salih Dincer
Feb 08, 2022
H. S. Teoh
Feb 09, 2022
user1234
Feb 09, 2022
bauss
Feb 09, 2022
bauss
Feb 09, 2022
user1234
Feb 09, 2022
Salih Dincer
Feb 08, 2022
matheus
Feb 09, 2022
forkit
Feb 09, 2022
forkit
February 08, 2022

Hope, D will go on to the next version,
the compiler will release up to v10!

Many happy returns of the (D)ay...🥳

  enum Dlang99 = 4026728633831507;

  union Magic
  {
    long data;
    char[8] bits;

    string toString()
    {
      return bits;
    }
  }
  auto magic = Magic(Dlang99<<10|'D');
       magic.writefln!"..::%s::..";
February 08, 2022
On Tue, Feb 08, 2022 at 06:19:55PM +0000, Salih Dincer via Digitalmars-d wrote:
> Hope, D will go on to the next version,
> the compiler will release up to v10!
> 
> Many happy returns of the (D)ay...🥳
> 
> ```d
>   enum Dlang99 = 4026728633831507;
> 
>   union Magic
>   {
>     long data;
>     char[8] bits;
> 
>     string toString()

In latest dmd git HEAD, you need to annotate this function with `return`, because it escapes a reference to `this`. :-)


>     {
>       return bits;
>     }
>   }
>   auto magic = Magic(Dlang99<<10|'D');
>        magic.writefln!"..::%s::..";
> ```


T

-- 
WINDOWS = Will Install Needless Data On Whole System -- CompuMan
February 08, 2022
On Tuesday, 8 February 2022 at 18:19:55 UTC, Salih Dincer wrote:
> Hope, D will go on to the next version,

It will end-up as a full circle, D started as better replacement for chaotic C++, it was even written in the latter and going neck to neck or even surpassing over the years, until it reached the point of "dog-fooding" and the compiler was rewritten in D, and now its direction is to be like D as a better C, it's incorporating stuffs like importC, and will eventually get rid of the GC, classes, templates... just to become a C's Doppelgänger. :)

Matheus.



February 09, 2022
On Tuesday, 8 February 2022 at 23:30:44 UTC, matheus wrote:
> On Tuesday, 8 February 2022 at 18:19:55 UTC, Salih Dincer wrote:
>> Hope, D will go on to the next version,
>
> It will end-up as a full circle, D started as better replacement for chaotic C++, it was even written in the latter and going neck to neck or even surpassing over the years, until it reached the point of "dog-fooding" and the compiler was rewritten in D, and now its direction is to be like D as a better C, it's incorporating stuffs like importC, and will eventually get rid of the GC, classes, templates... just to become a C's Doppelgänger. :)
>
> Matheus.

There appears to be a fundamental law of physics, whereby the natural tendency of things is to approach a chaotic state.

C++ already seems well on its way...

With D, the real question is, just how long can we delay this decay ;-)

February 09, 2022
On Wednesday, 9 February 2022 at 00:03:23 UTC, forkit wrote:
>

do the maths:

-(entropy) = k log (1/D)


February 09, 2022

On Tuesday, 8 February 2022 at 18:28:21 UTC, H. S. Teoh wrote:

>

On Tue, Feb 08, 2022 at 06:19:55PM +0000, Salih Dincer via Digitalmars-d wrote:

>

Hope, D will go on to the next version,
the compiler will release up to v10!

Many happy returns of the (D)ay...🥳

  enum Dlang99 = 4026728633831507;

  union Magic
  {
    long data;
    char[8] bits;

    string toString()

In latest dmd git HEAD, you need to annotate this function with return, because it escapes a reference to this. :-)

>
{
  return bits;
}

}
auto magic = Magic(Dlang99<<10|'D');
magic.writefln!"..::%s::..";

T

destroyer 2000

February 09, 2022
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"?


February 09, 2022
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;
}
```

Someone can correct me if I'm wrong, but I believe this is what he's referring to in the spec:

https://dlang.org/spec/function.html#return-ref-parameters
February 09, 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:

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::..";
}

February 09, 2022

On Wednesday, 9 February 2022 at 12:24:32 UTC, Martin Tschierschke wrote:

>

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:

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::..";
}

toString() should return a string, so what should happen is that the value of bits must actually be converted to string.

The error is evident if you ex. try to cast bits to string like this:

    string toString()
    {
      return cast(string)bits;
    }

Which will give this error:

onlineapp.d(12): Deprecation: returning `cast(string)this.bits` escapes a reference to parameter `this`
onlineapp.d(12):        perhaps annotate the parameter with `return`

So when we do:

    string toString() return
    {
      return cast(string)bits;
    }

There's no error.

Probably a terrible example and I'm not sure if casting like that is even considered safe or should even be done like that, but yeah...

« First   ‹ Prev
1 2