Tuesday, December 8, 2009
Last night I got the 'toString()' method working for enum constants:

var x = TestEnum.Rock;
Debug.assertEq("Rock", x.toString());

Speaking of toString, I haven't yet figured out what to call the "formatted toString" function. This is a version of toString that takes a single argument string which is the format spec, the equivalent of PEP 3101's '__format__' method. I don't want to use '__format__' because Tart doesn't use double underscores for special methods. (Rather, I just choose names that are sufficiently unique, such as "infixAdd".) Some variations I have considered are: toStringFmt, toStringF, toStringFormatted, but I'm not that happy with any of them.

I also fixed a couple of bugs in Type.of, so now you can say:

var ty:Type = Type.of(String);
Debug.assertEq("tart.core.String", ty.toString());
Debug.assertTrue(ty isa ComplexType);

... and so on.


Post a Comment