Re: [q-lang-users] Query about Type Tests (Complex and Rational).
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2006-06-15 22:00:54
|
John Cowan wrote: > I'm not sure I see the utility of this. Granted that non-numeric > types work this way, why should the numeric ones? I'd favor a scheme > in which you use the guards for syntactic types and the isX predicates > for semantic types. What can you do with iscomplex that you can't do > with a type guard? You can only use a type guard on the lhs of equations and variable definitions, whereas the predicates can be used everywhere on the rhs and on temporary computed values, too. So, yes, they are both useful. > Or if you think this is essential, how about going to a scheme in which > isX means "is it the representation type" and "is_X_number" means "does > it actually fit the model for that kind of number"? So iscomplex would > be true only of objects of type Complex, but is_complex_number would be > true of any number (except hypothetical quaternions and octonions to be > added later). That's a good idea! I can work out something along this line, but suggestions and code are welcome. > In particular, is_integral_number would be true of Floats with integer > values. A less verbose naming scheme would be good, though. Like isintnum, iscomplexnum, etc. Maybe we should also add isexact? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |