digitalmars.D - For the new std.variant
- Steve Teale (17/17) Oct 31 2011 Robert,
- Jesse Phillips (2/23) Oct 31 2011
- Steve Teale (25/26) Oct 31 2011 Jesse,
- Jesse Phillips (4/4) Oct 31 2011 I literally meant it is not supposed to exist. There was a suggestion to...
- Trass3r (2/6) Oct 31 2011 http://d.puremagic.com/issues/show_bug.cgi?id=5467
- Steve Teale (14/24) Oct 31 2011 OK, my use case is that in the database interface modules, as far as
- Robert Jacques (2/19) Oct 31 2011 As others have mentioned, typedef is being deprecated. That said, varian...
Robert, Maybe you can fix this along the way: import std.variant; struct B { int p, q, r, s; } typedef B C; void main() { B b; C c; b = c; // ok Variant v = c; assert(v.convertsTo!(B)); // no dice } Steve
Oct 31 2011
typedef shouldn't exist anymore, use alias. Steve Teale Wrote:Robert, Maybe you can fix this along the way: import std.variant; struct B { int p, q, r, s; } typedef B C; void main() { B b; C c; b = c; // ok Variant v = c; assert(v.convertsTo!(B)); // no dice } Steve
Oct 31 2011
On Mon, 31 Oct 2011 11:50:42 -0400, Jesse Phillips wrote:typedef shouldn't exist anymore, use alias.Jesse, Maybe you want to do something like: struct X { int a; double b; } typedef X Y; alias X Z; void discriminate(T)(T t) { if (is(T == X)) writeln("It's an X"); else writeln("No it's not"); } void main() { Y y; Z z; discriminate(y); discriminate(z); } Steve
Oct 31 2011
I literally meant it is not supposed to exist. There was a suggestion to even axe it from 2.056 I believe. A library solution is intended to be created which will allow for the type to act as either a parent or child to the type. So I understand its usage, but you shouldn't use it because it won't be there.
Oct 31 2011
I literally meant it is not supposed to exist. There was a suggestion to even axe it from 2.056 I believe.At least they prepared to actually deprecate it.A library solution is intended to be created which will allow for the type to act as either a parent or child to the type.http://d.puremagic.com/issues/show_bug.cgi?id=5467
Oct 31 2011
On Mon, 31 Oct 2011 21:03:39 +0100, Trass3r wrote:OK, my use case is that in the database interface modules, as far as possible I would like to infer an SQL type from a D type. There are often SQL types for TIME, DATE, DATETIME, and TIMESTAMP, but the latter two will usually correspond to D structs with the same members. I can define two identical structs with the same set of protocol parsing and packing methods, but with different names, but to me this seems clunky, error-prone, and not a very good advert for the language. There's was also a temptation to create typedefs of char[] like tinyString, mediumString and longString. I have not gone there - just as well. Forgetting typedef, which I should assume does not exist, what is the elegant approach to this? SteveI literally meant it is not supposed to exist. There was a suggestion to even axe it from 2.056 I believe.At least they prepared to actually deprecate it.A library solution is intended to be created which will allow for the type to act as either a parent or child to the type.http://d.puremagic.com/issues/show_bug.cgi?id=5467
Oct 31 2011
On Mon, 31 Oct 2011 06:30:40 -0400, Steve Teale <steve.teale britseyeview.com> wrote:Robert, Maybe you can fix this along the way: import std.variant; struct B { int p, q, r, s; } typedef B C; void main() { B b; C c; b = c; // ok Variant v = c; assert(v.convertsTo!(B)); // no dice } SteveAs others have mentioned, typedef is being deprecated. That said, variant now supports duck-typing. So 'v.to!B()' works. However, 'convertsTo's mandate is to test for implicit conversion, which isn't covered as there's no way in __traits to recover a typedef's base type.
Oct 31 2011