On Thu, Jun 26, 2008 at 04:03:42PM +0200, Moritz Lenz wrote: : In the test suite there are some tests like this: : is(1.WHAT, 'Int', '1 as a literal is an Int); : : This seems to imply that we guarantee the direct type of literals. But : do we? : : Actually I see no need for that. All my programs work fine if the : literal 1 is of type Foo, and Foo isa Int. : : What's our policy on that? Will a 1.WHAT always return Int? do we : guarantee (1..4).WHAT always to be 'Range'?
I don't see much problem with the direct type. While we can use any value as a type in a signature, it's really a subset type in that case, and subset types are never reported by WHAT because objects are officially stored in their standard representation for their base type. (Optimizers can cheat, of course.) So True.WHAT is Bool, but True is really a subset of Bool, because (False,True) is an enum of Bool, and enums are subset types. The optimizer is free to deduce that True and False don't really need a bit to represent them, but a Bool is naturally represented as a bit, so that is the offical base type of anything boolean. Likewise just because 1.WHAT returns Int doesn't mean the compiler has to represent 1 the same way it represents 42. But it wants to look that way from the viewpoint of the programmer, who pines for an occasional smattering of foolish consistency. Larry