Potential abuse of .stringof

Mike via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 9 23:59:43 PDT 2015


On Wednesday, 10 June 2015 at 00:50:48 UTC, Andrei Alexandrescu 
wrote:

> Exceptions: Voldemort types and function types.

Why not Voldemort types?

Example: http://dpaste.dzfl.pl/450dcdb5f7f8
-------------------------------------------
import std.stdio;

auto createVoldemortType(int value)
{
     struct TheUnnameable
     {
         int getValue() { return value; }
     }
     return TheUnnameable();
}

void main()
{
	auto voldemort = createVoldemortType(123);
	writeln(typeof(voldemort).stringof);
}
-------------------------------------------

Seems to return the correct result, although it "TheUnnameable" 
cannot be cut and pasted outside of the createVoldemortType 
scope.  Perhaps that's the limitation you are referring to.

Mike


More information about the Digitalmars-d mailing list