Qui, 2008-06-26 às 16:03 +0200, Moritz Lenz escreveu:
> 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'?

This is something I've been thinking about for some time. $a.WHAT is the
way to test for type identity, but allowing the user to expect a literal
to be from a specific given type is probably a bad idea, because

   (1..4).WHAT

should probably be ImplementationSpecificConstantCompactIntRange or
something like that. But I really think it's a matter of user
expectations, if we define that the effective type of the literals are
undetermined, the implementations will be free to use optimized types.

I think we should promote

   (1..4) ~~ Range

test, instead of

   (1..4).WHAT === Range

or even

   (1..4).WHAT eq 'Range'

daniel

Reply via email to