www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - OT: (C#) Type Unions for C#

reply ryuukk_ <ryuukk.dev gmail.com> writes:



and go submit a PR

Don't become a relic of the past, move forward

https://github.com/dotnet/csharplang/blob/main/proposals/TypeUnions.md

D should be leading, there is no reason for D to remain a relic 


Aug 02
next sibling parent reply Sergey <kornburn yandex.ru> writes:
On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a relic 


Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Aug 02
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 


Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Aug 02
next sibling parent Sergey <kornburn yandex.ru> writes:
On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 Bullshit, R&D already done many decades ago, it's a common 
 feature, it's not a novel thing
My answer is general, not only about these two things. Research is never stop =) GC, ownership and other things.
 https://odin-lang.org/docs/overview/#unions
If the language is big and has a lot of features you need a lot of resources for proper implementation, that all these things work flawlessly together.
 Fast compilation is the only thing that makes me resist from 
 porting my current game to an other language, and these 
 languages are getting there too..
https://github.com/nordlow/compiler-benchmark
 D should move forward, fast
If there will be more developers and contributors for sure :)
Aug 02
prev sibling parent reply user1234 <user1234 12.de> writes:
On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 
 relic of the past, no industry rely on D, yet they rely on 

Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Odin is far for being a model. Not self hosted, many bugs, poor implementation, poor test suite.
Aug 02
next sibling parent reply user1234 <user1234 12.de> writes:
On Friday, 2 August 2024 at 19:53:15 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 
 relic of the past, no industry rely on D, yet they rely on 

Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Odin is far for being a model. Not self hosted, many bugs, poor implementation, poor test suite.
It just takes me 1 minute to bring an evidence: - https://github.com/odin-lang/Odin/issues/4001 - https://github.com/odin-lang/Odin/commit/fdfe6b00e0e8558050ebd6e6c7cb33b3d789be4f nothing proves that this cannot break again. I see many things like this in Odin, Zig, Nim, V, etc. In my opinion, and as I consult often many PL bug trackers, there is a serious lack of methodology in all those "alt" languages, especially when they are hosted on GH...just to make some clicks.
Aug 02
parent reply ryuukk_ <ryuukk.dev gmail.com> writes:
On Friday, 2 August 2024 at 20:07:02 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 19:53:15 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 
 relic of the past, no industry rely on D, yet they rely on 

Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Odin is far for being a model. Not self hosted, many bugs, poor implementation, poor test suite.
It just takes me 1 minute to bring an evidence: - https://github.com/odin-lang/Odin/issues/4001 - https://github.com/odin-lang/Odin/commit/fdfe6b00e0e8558050ebd6e6c7cb33b3d789be4f nothing proves that this cannot break again. I see many things like this in Odin, Zig, Nim, V, etc. In my opinion, and as I consult often many PL bug trackers, there is a serious lack of methodology in all those "alt" languages, especially when they are hosted on GH...just to make some clicks.
Brother, don't be jealous, they are young languages, built by young people, they have a whole life ahead of them
Aug 02
parent user1234 <user1234 12.de> writes:
On Saturday, 3 August 2024 at 04:00:51 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 20:07:02 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 19:53:15 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 
 relic of the past, no industry rely on D, yet they rely on 

Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Odin is far for being a model. Not self hosted, many bugs, poor implementation, poor test suite.
It just takes me 1 minute to bring an evidence: - https://github.com/odin-lang/Odin/issues/4001 - https://github.com/odin-lang/Odin/commit/fdfe6b00e0e8558050ebd6e6c7cb33b3d789be4f nothing proves that this cannot break again. I see many things like this in Odin, Zig, Nim, V, etc. In my opinion, and as I consult often many PL bug trackers, there is a serious lack of methodology in all those "alt" languages, especially when they are hosted on GH...just to make some clicks.
Brother, don't be jealous, they are young languages, built by young people, they have a whole life ahead of them
Sorry for my previous words, they were not argumented. On top of that I would not like contributing to the "language war", so let me explain: I just cant stand his position on bootstraping. You see D had the same problem. You had to be a C++ programmer to contribute. Dont you see not to bootstrap is absurd ? At some point you propose something new instead of the old thing, but you have to master the old thing to contribute to the new thing. Just "comon you guys". If you are afraid of the self hosting process then just admit that fact and dont pretend that "self hosting before a stable language and compiler exists is masturbatory pleasure" (I quote).
Aug 06
prev sibling parent user1234 <user1234 12.de> writes:
On Friday, 2 August 2024 at 19:53:15 UTC, user1234 wrote:
 On Friday, 2 August 2024 at 10:54:59 UTC, ryuukk_ wrote:
 On Friday, 2 August 2024 at 10:43:56 UTC, Sergey wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:
 D should be leading, there is no reason for D to remain a 
 relic of the past, no industry rely on D, yet they rely on 

Only if some IT giant will decide to invest 100+ full-time professional devs into research and development :)
Bullshit, R&D already done many decades ago, it's a common feature, it's not a novel thing https://odin-lang.org/docs/overview/#unions Fast compilation is the only thing that makes me resist from porting my current game to an other language, and these languages are getting there too.. D should move forward, fast
Odin is far for being a model. Not self hosted, many bugs, poor implementation, poor test suite.
see https://odin-lang.org/docs/faq/#is-the-odin-compiler-self-hosted This is one of the most stupid thing I've ever read.
Aug 02
prev sibling next sibling parent Kagamin <spam here.lot> writes:

Aug 05
prev sibling parent reply Kapendev <alexandroskapretsos gmail.com> writes:
On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:

 DIPs


 DIP and go submit a PR
Maybe the OdinLang implementation might be a better inspiration: https://odin-lang.org/docs/overview/#unions
Aug 06
parent reply Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Tuesday, 6 August 2024 at 19:44:12 UTC, Kapendev wrote:
 On Friday, 2 August 2024 at 10:29:22 UTC, ryuukk_ wrote:

 DIPs


 DIP and go submit a PR
Maybe the OdinLang implementation might be a better inspiration: https://odin-lang.org/docs/overview/#unions
It seems Odin has type unions. I actually dislike their approach. IMO, you have two sane approaches: * Plus-like type sums where order doesn’t matter, duplication doesn’t matter and they auto-inline. The empty plus-like sum is `noreturn` and adding `noreturn` to a plus-like doesn’t actually add it, so that `S+(T+noreturn)` is another way to spell `T+S`. * Tag-based type unions where order matters, duplication matters (different tags), they do not auto-inline, and the empty one is at definition site its own type. From a plus-based type sum, you extract values asking for a value of some type. From a tag-based one, you request by tag.
Aug 12
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 12/08/2024 10:32 PM, Quirin Schroll wrote:
 Tag-based type unions where order matters, duplication matters 
 (different tags), they do not auto-inline, and the empty one is at 
 definition site its own type.
There is also tag based unions where order doesn't matter. I.e. hashed tag name/tag type. This is the one I propose, as it allows changing the sumtype elements without having to perform a match.
Aug 12
parent Quirin Schroll <qs.il.paperinik gmail.com> writes:
On Monday, 12 August 2024 at 10:37:08 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 On 12/08/2024 10:32 PM, Quirin Schroll wrote:
 Tag-based type unions where order matters, duplication matters 
 (different tags), they do not auto-inline, and the empty one 
 is at definition site its own type.
There is also tag based unions where order doesn't matter. I.e. hashed tag name/tag type. This is the one I propose, as it allows changing the sumtype elements without having to perform a match.
What I intended was writing “Non-tag-based type unions where order matters” etc. where you extract by index. For tag-based unions, you’re right, order should not matter, same as order of data members in a `union` type doesn’t matter. The gist is: There are actually four kinds of type sums: Plus-like, list-like, and ad-hoc and user-defined tagged. Examples: - JSON values are reasonable as a plus type: `alias Json = double + string + bool + Json[] + Json[string] + typeof(null)`. - Value exceptions are list-like: `Result = Expected ~ Unexpected1 ~ Unexpected2`. An unexpected type might be identical with `Expected` but semantically different. Even two unexpected results might be same-type but semantically different. If that’s not intended, one can use `Expected ~ (Unexpected1 + Unexpected2)`. - Most high-level user-defined sum types would be tag based. I implemented something like that some time ago in a library. What the library does is provide a mixin template so that users can create their own tag-based sum types. What it didn’t offer, though, was ad-hoc tag based unions, probably because of limiting syntax. I didn’t like seeing `Sum!(int, "x", long, "y")` in error messages because those things get long quickly. For the mixin template, I use an “implementation struct” that provides the types and members.
Aug 13