B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)

Jacob Carlborg doob at me.com
Fri Jan 18 10:23:11 UTC 2019


On 2019-01-17 23:44, H. S. Teoh wrote:

> YES!  This is the way it should be.  Type-tuples become first class
> citizens, and you can pass them around to functions and return them from
> functions
No no no, not only type-tuples, you want types to be first class 
citizens. This makes it possible to store a type in a variable, pass it 
to and return from functions. Instead of a type-tuple, you want a 
regular array of types. Then it would be possible to use the algorithms 
in std.algorithm to manipulate the arrays. I really hate that today one 
needs to resort to things like staticMap and staticIndexOf.

Of course, if we both get tuples and types as first class citizens it 
would be possible to store types in these tuples as well. But a tuple is 
usually immutable and I'm not sure if it would be possible to use 
std.algorithm on that.

It would be awesome to be able to do things like this:

type foo = int;

type bar(type t)
{
     return t;
}

auto u = [byte, short, int, long].map!(t => t.unsigned).array;
assert(u == [ubyte, ushort, uint, ulong];

-- 
/Jacob Carlborg


More information about the Digitalmars-d-announce mailing list