http://d.puremagic.com/issues/show_bug.cgi?id=596
--- Comment #8 from [email protected] 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 account; - The compiler has ways to optimize this code better (sometimes avoiding many runtime tests). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
