Jump to page: 1 25  
Page
Thread overview
From the D Blog: Crafting Self-Evident Code in D
Oct 03
zjh
Oct 03
zjh
Oct 03
rassoc
Oct 03
matheus
Oct 03
Martyn
Oct 03
bachmeier
Oct 03
Dom DiSc
Oct 03
matheus
Oct 03
user1234
Oct 03
matheus
Oct 04
claptrap
Oct 04
bachmeier
Oct 04
claptrap
Oct 04
bachmeier
Oct 05
claptrap
Oct 05
Dom DiSc
Oct 05
claptrap
Oct 05
angel
Oct 07
sighoya
Oct 08
sighoya
Oct 08
sighoya
Oct 28
bachmeier
October 02

It's been a long, long while since I published anything on the blog. I do intend to get pick it up again down the road, but Walter recently surprised me with plans of his own. He's taken the topic of his DConf '23 talk and derived a blog post from it:

https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/

I guess he got impatient with the pace at which I'm getting the talk videos uploaded :-)

And for anyone who'd like to engage in any Reddit discussion that comes up:

https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/

October 03

On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:

>

It's been a long, long while since I published anything on the blog.

Nice!

October 03

On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:

>

https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/

'enum { Yes, No }; is just an automatic “no hire” decision'

'No hire' for language designers who design sum types to be implicitly enumerated and convertible to integers and booleans?

October 03
On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:
> It's been a long, long while since I published anything on the blog. I do intend to get pick it up again down the road, but Walter recently surprised me with plans of his own. He's taken the topic of his DConf '23 talk and derived a blog post from it:
>
> https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/
>
> I guess he got impatient with the pace at which I'm getting the talk videos uploaded :-)
>
> And for anyone who'd like to engage in any Reddit discussion that comes up:
>
> https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/

Nice article but I think that I found a bug:

    g(f(e(d(c(b(a))),3)));

    a.b.c.d(3).e.f.g;

> "That’s the equivalent, but execution flows clearly left-to-right. Is this an extreme example, or the norm?"

Well I don't think they're equivalent:

    g(f(e(d(c(b(a))),3)));

I the first example "e" is receiving two arguments. While in the latter "d" is being receiving whatever "c" returns and "3".

Matheus.
October 03
On 03.10.23 09:36, Max Samukha via Digitalmars-d-announce wrote:
> 'No hire' for language designers who design sum types to be implicitly enumerated and convertible to integers and booleans?
import std.typecons;
void main() => assert(Yes.mate_hiringRedFlag);

October 03

On Tuesday, 3 October 2023 at 10:39:19 UTC, matheus wrote:

>

Nice article but I think that I found a bug:

g(f(e(d(c(b(a))),3)));

a.b.c.d(3).e.f.g;
>

"That’s the equivalent, but execution flows clearly left-to-right. Is this an extreme example, or the norm?"

Well I don't think they're equivalent:

g(f(e(d(c(b(a))),3)));

I the first example "e" is receiving two arguments. While in the latter "d" is being receiving whatever "c" returns and "3".

Matheus.

Agreed. Even though I do like UFCS, I find the above confusing to follow despite being more pleasing to the eye. I had to break it down and, as Matheus already pointed out, looked incorrect.

This appears to be the correct code.

int a() { return 1;  }
int b(int i) { return i+1; }
int c(int i) { return i+2; }
int d(int i) { return i+3; }
int e(int a, int b) { return a+b; }
int f(int i) { return i+4; }
int g(int i) { return i+5; }

void main()
{
    import std.stdio : writeln;
    auto r = g(f(e(d(c(b(a))),3)));
    auto r2 = a.b.c.d.e(3).f.g;

    writeln(r);    // 19
    writeln(r2);   // 19
}
October 03

On Tuesday, 3 October 2023 at 03:17:44 UTC, zjh wrote:

>

Nice!

chinese version.

October 03
On Tuesday, 3 October 2023 at 10:39:19 UTC, matheus wrote:
> I the first example "e" is receiving two arguments. While in the latter "d" is being receiving whatever "c" returns and "3".

That's the point. In UFCS it is immediately obvious which function receives the 3, while with all the parenthesis it takes some time and concentration to find out, and getting it wrong is quiet easy.
October 03

On Monday, 2 October 2023 at 17:28:19 UTC, Mike Parker wrote:

>

It's been a long, long while since I published anything on the blog. I do intend to get pick it up again down the road, but Walter recently surprised me with plans of his own. He's taken the topic of his DConf '23 talk and derived a blog post from it:

https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/

I guess he got impatient with the pace at which I'm getting the talk videos uploaded :-)

And for anyone who'd like to engage in any Reddit discussion that comes up:

https://www.reddit.com/r/programming/comments/16y2h36/crafting_selfevident_code_in_dlang/

A message specifically dedicated for you, Mike.

According to me there is a problem in the blog. Author and publication date should be put on top of an entry (currently the information are only at the bottom).

October 03
On Tuesday, 3 October 2023 at 13:33:29 UTC, Dom DiSc wrote:
> On Tuesday, 3 October 2023 at 10:39:19 UTC, matheus wrote:
>> I the first example "e" is receiving two arguments. While in the latter "d" is being receiving whatever "c" returns and "3".
>
> That's the point. In UFCS it is immediately obvious which function receives the 3, while with all the parenthesis it takes some time and concentration to find out, and getting it wrong is quiet easy.

I understand the advantages of the UFCS, I was just pointing out that the example given in that post are NOT equivalent, if it was deliberated or not I don't know, but I think it was just a small mistake, otherwise the author woundn't say they are equivalent.

Matheus.
« First   ‹ Prev
1 2 3 4 5