On May 27, 2010, at 12:43 AM, Dag Sverre Seljebotn wrote: > I recognized typeof in a recent commit by Robert. Is this a new > feature > in 0.13 or has it been in for some time?
It's been around since last fall--I just needed something quick for writing tests for type inference, so typeof was born. > If it is new: > > What I'm wondering is whether typeof should perhaps, in the spirit of > Python, return a descriptive object instead of a string. (It could > even > return a ctypes object describing the type, if that is powerful enough > for us). > > In particular, it should be possible to do introspection about structs > and so on, so that it is easy to build serializers etc. using "typeof" > information. (Buffers already put some RTTI about structs to the C > file > BTW, in order to parse buffer format strings.) > > This is thinking long-term; but I'm wondering whether the current > typeof > should be renamed e.g. "nameoftype", in order to maintain backwards > compatability if or when somebody decides to make a more powerful > typeof. I was thinking of that at first, but I really can't think of much one would do with it--it's not giving anything that's not known at compile time, it's just a way to make sure the compiler thinks the type is what you think it is. Even with templates, it would return the template parameter, not the resolved type. For testing purposes, a string is very nice. - Robert _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
