November 28, 2022
On 11/28/2022 4:02 PM, deadalnix wrote:
> I'd like to point out that we still don't have a reasonable collection library because it is not possible to have a user type that has properties similar to a slice (as in T[]).
> 
> Solving this would also ensure ensure that we can have sumtype as a library that are just as good as the builtin ones. The reason we cannot now is because we cannot build library types that mimic the builtin ones.
> 
> I would have liked you as a leader here to get people to focus here instead of adding to the pile of complexity.
> 
> There is a runaway pattern in this community to chase the next great thing, not because it is is bringing that much value, but because that's a good distraction from the fundamentals problems that exists.

It would be nice if you enumerated those fundamental problems. I don't know what they are.
November 28, 2022
I agree, it's clear that sumtypes are pretty much required in a modern language.
November 29, 2022

On Tuesday, 29 November 2022 at 00:48:32 UTC, max haughton wrote:

>

Built-in sumtypes will unify a lot of codebases if done right: Tuples and sumtypes are to writing beautiful programs what the container issues are to writing beautiful libraries IMO.

Unifying and yada yada are all very nice sounding words, but I'm afraid this is not very actionable.

Here is the deal. We can agree that this is useful. Great. Now step back and look at the larger picture.

The number of people who would use D if we changed nothing to the current thing but sum type is exactly 0. Maybe 1 if stars align properly.

In the same way traction control is a great feature to have on you car, but none of this matter when the passenger door cannot close. And the passenger door is not closing right now.

This forum is full of problem that actual people have trying to write actual D code. See https://forum.dlang.org/thread/nzlnwbcezwyopjfiasan@forum.dlang.org for instance from just today.

A grand total of none of these problems people are facing would be addressed by sum types. Not even one, kind of, if you are squinting hard enough while blind drunk.

In fact, this is especially funny because I have spent the last several day implementing what effectively amount to a sum type in D. While having a syntax to express sum type would have been nice, I don't doubt that, nothing on that front is a blocker. What's a blocker is that some of types packed in the sum are collection and I can't get them to behave right, because the way I need them to behave like builtin slice, but I cannot.

I'm literally building a sum type, and I'm telling, NO amount of integration of sum type into the language would change anything about the practical problem I'm facing working on this, it would just enable less boilerplate in part of the code that have no problems.

Certainly, less boilerplate is good, but I'm trying to get shit done. Boilerplate is workable. Broken type system is not.

You guys need an intervention. I'm serious.

November 29, 2022

On Monday, 28 November 2022 at 21:22:55 UTC, Walter Bright wrote:

>

On 11/28/2022 7:53 AM, IGotD- wrote:

>

Actually creating a preview as well can help as then programmers can try it out an observe how behaves in their own code. That can be valuable input for the DIP.

Implementing it will be a substantial amount of work (as opposed to the trivial ImportC), so I'm reluctant to do so without a pretty positive response.

Can a dip be similar to a plug-in? As long as the dip author implements the corresponding interface, there will be a command line preview for it automatically?

November 29, 2022
On Tuesday, 29 November 2022 at 01:27:32 UTC, Walter Bright wrote:
> It would be nice if you enumerated those fundamental problems. I don't know what they are.

I have done so numerous times. Every single god damn time you answer the same thing.

IT IS NOT POSSIBLE TO WRITE A COLLECTION IN D THAT BEHAVE PROPERLY AS PER THE TYPE SYSTEM'S RULES.

Is that big enough? vector? Set? Map? Does any of it ring a bell? Even range code completely shits the best as long as you throw a const in there.

Type qualifier do not turtle down (Vector!int and Vector!const(int) are completely unrelated constructs), the top level qualifier need to be able to pop when things are passe by value, etc...

You know what these behavior are, there are the one of builtin slices. This is not random, this is the behavior that is needed for containers, range, and, for that matter, sum types.

Adding more stuff on top of broken foundations achieve only one goal: an increase complexity. Because none of these things are the actual bottleneck for anyone.

Would I want tuples, sum types and whatnot, assuming the core language was not full of bear traps? Yes. Absolutely. Let's talk about it when the bear trap situation is under control. Because none of this is useful.
November 29, 2022
On 29/11/2022 3:33 PM, deadalnix wrote:
> Certainly, less boilerplate is good, but I'm trying to get shit done. Boilerplate is workable. Broken type system is not.
> 
> You guys need an intervention. I'm serious.

Broken and incomplete implementations too.

Seriously, 2-3 days an actual dmd compiler dev could probably get ModuleInfo exportation on Windows working correctly and we could get shared library support in D starting to actually be decent.

Just that one fix would mean we could close FOUR issues extremely easily! And add a whole new realm of possibilities for D.
November 29, 2022
On Tuesday, 29 November 2022 at 02:33:21 UTC, deadalnix wrote:
> I'm literally building a sum type

Curious, what did you find lacking in std.sumtype?

Same question to Walter.

(btw I've never used it myself but this seems an obvious question that needs to be answered by anyone doing their own implementation, in or out of the language)
November 28, 2022

On 11/28/22 9:42 PM, deadalnix wrote:

>

On Tuesday, 29 November 2022 at 01:27:32 UTC, Walter Bright wrote:

>

It would be nice if you enumerated those fundamental problems. I don't know what they are.

I have done so numerous times. Every single god damn time you answer the same thing.

IT IS NOT POSSIBLE TO WRITE A COLLECTION IN D THAT BEHAVE PROPERLY AS PER THE TYPE SYSTEM'S RULES.

This is pretty harsh for the single problem you bring up, which I agree would be nice to fix, but absolutely is not a fundamental problem for having containers in D.

Yes, if you have the same problem over and over again, it's frustrating to have it continually ignored or dismissed. But it's also not possible to always search this forums for all the times it was brought up. Half the time, I don't remember conversations that I have had on these forums, and sometimes I sheepishly discover that I had the opposite opinion some years ago.

So please let's discuss this problem in a productive way. The problem is that there's no syntax to "tail-modify" a type other than a pointer or an array. This is the biggest problem with properly using const on ranges (it doesn't prevent using const containers, or prevent ranges to const data, it just prevents taking a range to a mutable container and iterating it via a const parameter).

I think I've been bringing this problem up for 10 years. It would be a huge win to get it solved.

-Steve

November 29, 2022

On Tuesday, 29 November 2022 at 03:03:37 UTC, Steven Schveighoffer wrote:

>

The problem is that there's no syntax to "tail-modify" a type other than a pointer or an array. This is the biggest problem with properly using const on ranges (it doesn't prevent using const containers, or prevent ranges to const data, it just prevents taking a range to a mutable container and iterating it via a const parameter).

I think I've been bringing this problem up for 10 years. It would be a huge win to get it solved.

The thing is, we pretty much know what the solution is. In the general case, solving this requires user-defined implicit conversions, because in the general case only the user has the knowledge necessary to establish the correspondence between a templated type's structure (e.g., "the head-mutable version of const(Foo!T)") and its name (e.g., Foo!(const(T))).

The problem is, that solution has been declared categorically off the table, so we are stuck going in circles debating the merits and shortcoming of various half-measures.

November 29, 2022

On Tuesday, 29 November 2022 at 02:33:21 UTC, deadalnix wrote:

>

On Tuesday, 29 November 2022 at 00:48:32 UTC, max haughton wrote:

>

Built-in sumtypes will unify a lot of codebases if done right: Tuples and sumtypes are to writing beautiful programs what the container issues are to writing beautiful libraries IMO.

Unifying and yada yada are all very nice sounding words, but I'm afraid this is not very actionable.

Here is the deal. We can agree that this is useful. Great. Now step back and look at the larger picture.

The number of people who would use D if we changed nothing to the current thing but sum type is exactly 0. Maybe 1 if stars align properly.

I have met a few people who were specifically turned off of D because they wanted real algebraic data types and pattern matching - as in "that's cute, where's the real thing" when shown library sum types.

>

In the same way traction control is a great feature to have on you car, but none of this matter when the passenger door cannot close. And the passenger door is not closing right now.

This forum is full of problem that actual people have trying to write actual D code. See https://forum.dlang.org/thread/nzlnwbcezwyopjfiasan@forum.dlang.org for instance from just today.

A grand total of none of these problems people are facing would be addressed by sum types. Not even one, kind of, if you are squinting hard enough while blind drunk.

Well one is template bloat. I happily (well, readily) concede this is relatively minor compared to the type system as a whole but instantiating any operation on a sumtype is not cheap. One of the primary complaints is the build and link time which usually means some kind of explosive template code.

Especially when you consider a lot of this code is actually thrown away i.e. used to check if such and such a thing is true.

I will also note that "actual" people both informally and in a few surveys we've done over the years do consistently ask for this. We don't have to be democracy but an appeal to actual developer's work should be aware of that.

>

In fact, this is especially funny because I have spent the last several day implementing what effectively amount to a sum type in D. While having a syntax to express sum type would have been nice, I don't doubt that, nothing on that front is a blocker. What's a blocker is that some of types packed in the sum are collection and I can't get them to behave right, because the way I need them to behave like builtin slice, but I cannot.

In what way specifically? const-ness?

I also note that many many codebases have something that amounts to a sum type one way or another. As a result of that we have many incompatible sumtype implementations. They're also completely opaque to tooling.

>

I'm literally building a sum type, and I'm telling, NO amount of integration of sum type into the language would change anything about the practical problem I'm facing working on this, it would just enable less boilerplate in part of the code that have no problems.

Without knowing the problem in more detail I have nothing. Even if the solution was hacky it's better to have magic contained in something the compiler controls then a foreign library IMO.

>

Certainly, less boilerplate is good, but I'm trying to get shit done. Boilerplate is workable. Broken type system is not.

Lack of boilerplate comes as a result of integration into the language, alongside correctness, it's not a goal in and of itself beyond informing a design.

Boilerplate in this case does, however, fundamentally change the code I reach for. You can criticize this as being one step away from code golf but currently some hierarchies in D code go from being a careful idea in ones head (I hesitate to say abstraction because true abstraction is not necessarily achieved) to a bunch of unnecessary spew.

It isn't so much boilerplate with library sumtypes being the issue as much that they're just annoying enough that they aren't the obvious choice.