Jump to page: 1 213  
Page
Thread overview
draft proposal for Sum Types for D
Nov 29, 2022
Walter Bright
Nov 29, 2022
Daniel N
Nov 29, 2022
Walter Bright
Nov 29, 2022
ryuukk_
Nov 29, 2022
Basile B.
Nov 29, 2022
Walter Bright
Nov 29, 2022
Andrey Zherikov
Nov 29, 2022
Andrey Zherikov
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Max Samukha
Nov 29, 2022
Walter Bright
Nov 29, 2022
Dark Hole
Nov 29, 2022
Walter Bright
Nov 29, 2022
ryuukk_
Nov 29, 2022
rikki cattermole
Nov 29, 2022
ryuukk_
Nov 29, 2022
Per Nordlöw
Dec 02, 2022
Walter Bright
Nov 29, 2022
Paulo Pinto
Dec 02, 2022
Walter Bright
Nov 29, 2022
XavierAP
Nov 29, 2022
jmh530
Nov 29, 2022
jmh530
Nov 29, 2022
jmh530
Nov 29, 2022
rikki cattermole
Nov 29, 2022
Timon Gehr
Nov 29, 2022
rikki cattermole
Nov 29, 2022
oconnor0
Nov 29, 2022
rikki cattermole
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Timon Gehr
Nov 30, 2022
Walter Bright
Nov 30, 2022
Timon Gehr
Nov 29, 2022
Timon Gehr
Nov 29, 2022
jmh530
Nov 30, 2022
Walter Bright
Nov 30, 2022
Timon Gehr
Nov 29, 2022
Timon Gehr
Dec 02, 2022
Walter Bright
Dec 02, 2022
Max Samukha
Dec 02, 2022
Max Samukha
Dec 02, 2022
Andy
Dec 02, 2022
Tejas
Dec 02, 2022
Paul Backus
Dec 02, 2022
deadalnix
Dec 02, 2022
rikki cattermole
Dec 02, 2022
Timon Gehr
Dec 02, 2022
TheGag96
Nov 29, 2022
Timon Gehr
Nov 30, 2022
Quirin Schroll
Dec 05, 2022
Kagamin
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Timon Gehr
Nov 29, 2022
12345swordy
Nov 29, 2022
rikki cattermole
Nov 29, 2022
Per Nordlöw
Nov 29, 2022
Timon Gehr
Nov 29, 2022
deadalnix
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Walter Bright
Nov 29, 2022
Walter Bright
Nov 29, 2022
Timon Gehr
Nov 29, 2022
H. S. Teoh
Nov 29, 2022
rikki cattermole
Nov 30, 2022
Paul Backus
Nov 30, 2022
deadalnix
Nov 29, 2022
IGotD-
Nov 29, 2022
Timon Gehr
Nov 29, 2022
Per Nordlöw
Nov 30, 2022
Walter Bright
Nov 30, 2022
Paolo Invernizzi
Nov 29, 2022
Jacob Carlborg
Nov 29, 2022
H. S. Teoh
Nov 29, 2022
Timon Gehr
Nov 30, 2022
Basile.B
Nov 30, 2022
Walter Bright
Nov 30, 2022
Walter Bright
Nov 30, 2022
Adam D Ruppe
Dec 02, 2022
Walter Bright
Nov 30, 2022
Andrey Zherikov
Nov 30, 2022
Zealot
Nov 30, 2022
Basile.B
Nov 30, 2022
Basile.B
Dec 03, 2022
Basile B.
Dec 03, 2022
H. S. Teoh
Dec 03, 2022
Basile B.
Dec 02, 2022
Walter Bright
Nov 30, 2022
Quirin Schroll
Dec 01, 2022
zjh
Dec 05, 2022
Jacob Shtokolov
Dec 05, 2022
Paul Backus
Dec 05, 2022
Jacob Shtokolov
Dec 05, 2022
Paul Backus
Dec 06, 2022
ryuukk_
Dec 06, 2022
Paul Backus
Dec 06, 2022
ryuukk_
Dec 06, 2022
Meta
Dec 06, 2022
ryuukk_
Nov 30, 2022
Guillaume Piolat
Nov 30, 2022
Hipreme
Nov 30, 2022
H. S. Teoh
Dec 01, 2022
Hipreme
Dec 01, 2022
Guillaume Piolat
Dec 01, 2022
ryuukk_
Dec 01, 2022
ryuukk_
Dec 01, 2022
Hipreme
Nov 30, 2022
RTM
Dec 01, 2022
cc
Dec 01, 2022
cc
Dec 02, 2022
JN
Focus (was Re: draft proposal for Sum Types for D)
Dec 03, 2022
John Colvin
Dec 03, 2022
Bruce Carneal
Dec 03, 2022
Stefan Koch
Dec 03, 2022
bachmeier
Dec 03, 2022
CM
Dec 03, 2022
rikki cattermole
Dec 03, 2022
ryuukk_
Dec 05, 2022
Kagamin
Dec 04, 2022
zjh
Dec 04, 2022
zjh
Dec 05, 2022
Kagamin
Dec 03, 2022
Andrey Zherikov
Dec 03, 2022
cc
Dec 05, 2022
Kagamin
November 28, 2022
Go ahead, Make My Day! Destroy!

https://github.com/WalterBright/DIPs/blob/sumtypes/DIPs/1NNN-(wgb).md
November 29, 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

Cool, what about 'switch' support?
November 29, 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 have the feeling that there are several cases where you use `enum thing {...}` instead of `sumtype thing {...}`, this creates a bit of confusion.
November 29, 2022

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

This is very nice!

Few comments:

This looks like a typo making recursive grammar:

SumTypeMembers:
    SumTypeMembers     // should it be SumTypeMember?
    SumTypeMember `,`
    SumTypeMember `,` SumTypeMembers
>

?x.allow ? x.allow : Xyzzy.busy

Can this be shortened to ?x.allow : Xyzzy.busy?

>

But since a subtype with only enum members can be implemented as an enum, the compiler should do that rewrite. Similarly, a SumType with only one field declaration should be rewritten as a struct (and the tag can be omitted).

How will ?x.allow be rewritten in these cases?

Other questions:
How will this work with Enum Type Inference?
Can this be used as an implementation of optional built-in type in the future? (IMO this should be another DIP but would like to get your thoughts)

November 29, 2022

Few other things that I think should be clarified:

Will sumtype support UDAs for its members?
How will __traits work for sumtype (especially allMembers and getMember)?

November 29, 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 guess 'void' will continue to be an abominable special case?

sumtype Result(T)
{
    error;
    result(T);
}

Result(T) bar(alias foo)()
{
    alias R = Result!(typeof(foo()));
    return whatever ? R.result(foo()) : R.error;
}

int baz() { return 0; }
void qux() {}

bar!baz(); // fine
bar!qux(); // no way?
November 29, 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 understand read code:

Xyzzy x = Xyzzy.busy;
Xyzzy y = x.busy; // ok
y = x.allow;      // runtime error
y = ?x.allow ? x.allow : Xyzzy.busy;
x = Xyzzy.allow(3);
y = x.allow;      // ok

As I thought the type of x.allow is int and x.busy is (probably) void. But then we assigning them to y which type is Xyzzy. How should it work? Implicit cast? Or it should be read like y = ?x.allow ? x : assert(0)?

Also what will be in nothrow code? Can we access members of sumtype?

November 29, 2022
On 11/28/2022 11:18 PM, Daniel N wrote:
> Cool, what about 'switch' support?

I think you mean a match statement. Another DIP for that.
November 29, 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

What if I game the compiler changing the declaration order?

sumtype Pointer
{
    int* Ptr,
    Null,
}

or if I have multiple pointer based cases,

sumtype Pointer
{
    int* Ptr,
    Null,
    int* AnotherPtr,
}

or only the pointers,

sumtype Pointer
{
    int* Ptr,
    int* AnotherPtr,
}


From my point of view this should at very least be a compiler error in @safe, or the compiler needs to be smart enough to ensure there is at least a non-pointer case and it must be the zero index one.
November 29, 2022
On 11/28/2022 11:30 PM, Basile B. wrote:
> I have the feeling that there are several cases where you use `enum thing {...}` instead of `sumtype thing {...}`, this creates a bit of confusion.

I would never make a mistake like that!
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11