December 03, 2022
On 03/12/2022 10:28 AM, deadalnix wrote:
> On Friday, 2 December 2022 at 16:43:45 UTC, Tejas wrote:
>> Is it possible to make the syntax `int|float|char` style? We could parameterize it as `alias type(T) = int|float|customType!T;`
>>
>> Or will it mess with bitwise expressions too much? It _kinda_ shouldn't since all the operands in bitwise or are variables, but here they will _all_ be types
> 
> It 100% will, because the next step in enlightenment here is to realize that literal are also types with one value, and that the definitively belong in there.

Yeah its better that we stick to ``sumtype Identifier = Arg1|Arg;`` syntax instead where binary operators don't have to be supported (except inside brackets).

Slightly unfortunate since that means we can't define it as part of a return type of a function or as a parameter.
December 03, 2022

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I don’t want to be discouraging of good work, but D is not lacking in great features, it is lacking in its implementation of the basics.

I have come to believe over several years working in D, managing work in D at some scale (10s of devs, not 100s) & advocating for D that the foundations are shaky and crumbly and need work.

While it is not possible to implement a struct as drop-in replacement for a built in slice, while template symbol emission bugs keep happening[1], while the built in AAs are not in great shape (and the signature of toHash is a PITA), while the compiler is a huge memory hog and compile times for templates get wild, while speculative compilation results somehow go wrong and leak in to the non-speculative parts of compilation (e.g. https://issues.dlang.org/show_bug.cgi?id=19545), while syntax changes happen without enough noise (so even basic tooling ends up breaking), while shared and property and synchronised classes and so on sit in poor and/or incomplete shape, while delegate contexts still have qualifier problems[2]…

Why would the limited resources available be focused on a built-in sum type?

D is an amazing language. “Another killer feature” isn’t the missing piece to it getting some real, persistent, large-scale traction. They key is the rock solid basics and the cleaning up of lingering nonsense. Then the features can come, if they need to, because everyone loves building features and the more the basics are sorted out the easier it will be to add more.

The really committed and talented people here need to choose quality and build it.

I think D has a culture of accepting all sorts of badness while promising greatness, which is self-limiting.

I have poured a unbelievable number of hours in to D over the years, both commercially and open source, it has formed the backbone of my career, I want to see it succeed, but this will not happen if the basics are not dealt with.

I’m happy talk more about this with any of the core developers, I may not write a lot more out here as I don’t want to keep ladling on negativity in public, but for a variety of reasons I think change is needed.

[1] please no “where’s the bug report”, it’s whackamole. There needs to be a reckoning with the fundamental nature of the problem. Does anyone even understand the current design & implementation?

[2] this is pretty much what I could think of off the top of my head. I’m sure there’s more!

December 03, 2022

On Saturday, 3 December 2022 at 16:17:19 UTC, John Colvin wrote:

>

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I don’t want to be discouraging of good work, but D is not lacking in great features, it is lacking in its implementation of the basics.

I have come to believe over several years working in D, managing work in D at some scale (10s of devs, not 100s) & advocating for D that the foundations are shaky and crumbly and need work.

... many well reasoned points supporting the above ...

Well put.

>

[1] please no “where’s the bug report”, it’s whackamole. There needs to be a reckoning with the fundamental nature of the problem. Does anyone even understand the current design & implementation?

The benefits of an alternate front end development effort have never been clearer.

December 03, 2022

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

Actually why not to introduce optional type first and then base sumtype implementation on optional saying that sumtype_obj.value yields to optional of type typeof(sumtype_obj.value)?

Offtopic about strictly non-null pointers: what's about int*! ptr syntax? a pointer that can be null: int*? ptr. And the regular pointer (int* ptr) can be, for example, force-treated as int*! ptr or int*? ptr based on compiler option.

December 03, 2022

On Saturday, 3 December 2022 at 16:17:19 UTC, John Colvin wrote:

>

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I don’t want to be discouraging of good work, but D is not lacking in great features, it is lacking in its implementation of the basics.
[...]

Yep. I 100% agree.

The issue with D right now are not the bells and whistles.
It's the bread and butter.

As for the template emission, having been away from the issues and scene for a while made me realize the reason of the emission issues.
It's that we cannot emit the same symbol twice.

@Ibuclaw if I am correct at least that would be solved by making template instances weak symbols no?

If we did that we could remove some complexity from the emission.

December 03, 2022

On Wednesday, 30 November 2022 at 14:32:56 UTC, Basile.B wrote:

>

On Wednesday, 30 November 2022 at 14:22:08 UTC, Basile.B wrote:

>

On Wednesday, 30 November 2022 at 08:49:00 UTC, Andrey Zherikov wrote:

>

[...]

That would not generally work, or that would not be efficient. In the background "optional access" allocates a default value at the use site, meanings an alloca, and then you select the default or the right one if evaluation has succeed. Optional access is more tied to the language. Optional access does not generate good unoptimized code, let's not making its D version worst that what already exists.

You see a thing like

a?.b = c

is like

typeof(a.b) fallback;
(a.b ? a.b : fallback) = c;

where the ternary yields a lvalue.

This causes problems with members that will be eventually used in optional accesses. The default value must be related to that particular expression.

Using a sum type for optional access is still a hack.

TLDR; I mean the member of an aggregate is not necessarily a sumtype, but you want optional access on it. Because of that I think that optional access should be a well defined expression in a language. Let's not merge two things because they partially intersect.

// let me explain the problem
// you want optional access

struct S
{
    int a;
}

// so you cant get optional access to `a`
// because "int" does not allows this so
// you write

struct S
{
    SomeSumtype a;
}

// nice but it's not anymore compatible with C
// the optional value is part of the struct size
// you see the problem ?
//
// your struct size is not anymore 4 but 8.
//
// Optional access must be built in the language as an operator.

you see what I mean ?

December 03, 2022
On Sat, Dec 03, 2022 at 05:26:41PM +0000, Basile B. via Digitalmars-d wrote: [...]
> ```d
> // let me explain the problem
> // you want optional access
> 
> struct S
> {
>     int a;
> }
> 
> // so you cant get optional access to `a`
> // because "int" does not allows this so
> // you write
> 
> struct S
> {
>     SomeSumtype a;
> }
> 
> // nice but it's not anymore compatible with C
> // the optional value is part of the struct size
> // you see the problem ?
> //
> // your struct size is not anymore 4 but 8.
> //
> // Optional access must be built in the language as an operator.
> ```
> 
> you see what I mean ?

I don't follow.  Whether or not the sum type is built into the language, the tag has to be stored *somewhere*, your struct size will not be compatible with C regardless.  Just because .a uses a built-in sumtype does not make the tag disappear into thin air, it will still exist in the struct and occupy space, and the result is still not compatible with C because C does not understand sumtypes.

Either way, on the C side you have to declare the tag explicitly and deal with it explicitly, regardless of whether sumtypes are built into the language or not.


T

-- 
"I'm not childish; I'm just in touch with the child within!" - RL
December 03, 2022

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I like the a | b | c syntax, because the simpler and cleaner it is to use a tool suitable for efficient expressive error checking, the more likely I'll be to actually use it to implement error checking. The seductive alternative in my experience will always be "Ehh, error checking? What a hassle. I'll wrap everything in try/catch tomorrow... maybe."

December 03, 2022

On Saturday, 3 December 2022 at 16:17:19 UTC, John Colvin wrote:

>

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I don’t want to be discouraging of good work, but D is not lacking in great features, it is lacking in its implementation of the basics.

I agree. The question is who other than Walter is going to do this. These are the things that, IMO, Walter should not even be part of.

December 03, 2022

On Saturday, 3 December 2022 at 16:17:19 UTC, John Colvin wrote:

>

On Tuesday, 29 November 2022 at 06:26:20 UTC, Walter Bright wrote:

>

Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md

I don’t want to be discouraging of good work, but D is not lacking in great features, it is lacking in its implementation of the basics.

[...]

SDC seems to be a pathway to a nicer frontend, at least. Would love to see its representation at the meetings.