Re: Is std.variant.visit not @nogc?

2018-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/10/18 12:59 PM, Paul Backus wrote: On Tuesday, 10 April 2018 at 12:34:07 UTC, aliak wrote: Awesome! this is a neat trick: union {   AliasSeq!(T0, T1) values; } Is that usage documented somewhere, or is it somewhere in phobos maybe? Also, can Algebraic be fully replaced with this

Re: Is std.variant.visit not @nogc?

2018-04-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 12:34:07 UTC, aliak wrote: Awesome! this is a neat trick: union { AliasSeq!(T0, T1) values; } Is that usage documented somewhere, or is it somewhere in phobos maybe? Also, can Algebraic be fully replaced with this version then or is there some functionality

Re: Is std.variant.visit not @nogc?

2018-04-10 Thread aliak via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 03:48:25 UTC, Paul Backus wrote: Nope! It's just a tagged union, almost exactly the same as what you'd write by hand in C. You can take a look at the source yourself, if you're curious---it's actually pretty simple:

Re: Is std.variant.visit not @nogc?

2018-04-09 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 April 2018 at 00:22:18 UTC, helxi wrote: On Monday, 9 April 2018 at 15:59:32 UTC, Paul Backus wrote: On Monday, 9 April 2018 at 07:07:58 UTC, Chris Katko wrote: [...] I agree in general, but in this case it's actually completely doable. In fact, I've done it myself: check out

Re: Is std.variant.visit not @nogc?

2018-04-09 Thread helxi via Digitalmars-d-learn
On Monday, 9 April 2018 at 15:59:32 UTC, Paul Backus wrote: On Monday, 9 April 2018 at 07:07:58 UTC, Chris Katko wrote: [...] I agree in general, but in this case it's actually completely doable. In fact, I've done it myself: check out 'sumtype' on code.dlang.org. You can replace

Re: Is std.variant.visit not @nogc?

2018-04-09 Thread Paul Backus via Digitalmars-d-learn
On Monday, 9 April 2018 at 07:07:58 UTC, Chris Katko wrote: On Monday, 9 April 2018 at 07:02:50 UTC, Hasen Judy wrote: IMO, this is one more reason why sum-types should be built into the language compiler, instead of being implemented in user-space. +1. Any time you have to "create" a

Re: Is std.variant.visit not @nogc?

2018-04-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 April 2018 at 03:20:58 UTC, helxi wrote: Is std.variant.visit not @nogc? These error messages REALLY need to be fixed. visit, being a template, is @nogc or not based on the arguments passed to it as well as its own body, so while the error messages point to visit itself

Is std.variant.visit not @nogc?

2018-04-08 Thread helxi via Digitalmars-d-learn
); } } Complains source/app.d(18,19): Error: @nogc function D main cannot call non-@nogc function std.variant.visit!(function (string s) => printf("%s\x0a", cast(immutable(char)*)s), function (int n) => printf("%i\x0a", n)).visit!(VariantN!(16LU, int, string)).visi