----- Original Message ---- > From: Jonathan Worthington <jonat...@jnthn.net>
> > subset Even of Int where { not $_ % 2 }; > > my Even $num = 2; > > say $num; > > say $num.WHAT; > > > > > > Output: > > > > 2 > > Int > > I'm expecting: > > > > 2 > > Even > > > > > I think the current behaviour is correct (or at least, implemented to match > my > understanding of the Perl 6 type system). You're asking for the type of the > value stored in $x, which is an Int. > > Even is not a "real type", but rather a refinement type. It is set as a > constraint on what may be held by the container. To get hold of that (though > I > don't think we implement any way right now) you probably would write > $x.VAR.type > or some such (I'm not sure exactly what the name of the method on the > container > that hands this back should be). Really? It subset looks to me like a new type definition, built on an existing type. If that was the case, then this would look normal: my Int $foo; say $foo.WHAT; # Int my Odd $bar; say $bar.WHAT; # Odd That *looks* right to me, particularly since what comes after the "my" seems like a type declaration. By your logic, .WHAT refers to the value, not the container, which seems odd. That being said: my $foo = 3; say $foo; # Int $foo = 'stuff'; say $foo; # Str So that's probably bad coding (reusing a variable for different types) but it's legal. So maybe this is the correct behavior, but I expect it's going to confuse people. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog - http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6