--- Comment #8 from 2011-09-28 19:13:23 PDT ---
Supporting something like this will be very useful (this is done very commonly
in functional languages):

import std.variant: Algebraic;
alias Algebraic!(int, float) A;
void main() {
    A a = 1.5;
    final switch (a.type()) {
        case typeid(int): ...
        case typeid(float): ...        

But if possible I suggest to introduce a compiler optimization specific for
this usage, to avoid actually allocating and using TypeInfo class instances.

The advantage of using a final switch instead of a sequence of if statements:
- The code is more readable, the various cases are shown in a more ordered way;
- The "final" of switch makes sure all types of the Algebraic are taken into
- The compiler has ways to optimize this code better (sometimes avoiding many
runtime tests).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to