On Tue, Jan 28, 2020 at 08:27 Trey Harris <t...@lopsa.org> wrote: > On Mon, Jan 27, 2020 at 23:57 ToddAndMargo via perl6-users < > perl6-users@perl.org> wrote: > >> Hi Al, >> >> Now what am I doing wrong? >> >> > my Int $u = 0xF8; say $u.Range; >> >> Invocant of method 'Range' must be a type object of >> type 'Int', not an object instance of type 'Int'. >> Did you forget a 'multi'? >> >> When is an Int not an Int? > > > This false statement illustrates: “0xF8 (248) is evenly divisible by 31. > 248 is an Int. Therefore, an Int is evenly divisible by 31.” That’s the > difference. One is the idea of an Int, the other is a particular Int. > > In practice, this means that you can get a .Range operation out of the Int > type (without arguments, a.k.a. just `Int.Range`, it is the range of all > integers from -Inf to Inf), but not out of a particular Int. > > That would not be well-defined: would it be the range of Ints from zero to > the given Int, from 1 to the given Int, or from something different > depending on if the Int is a positive or negative number, and would > $negativeInt.Range go backwards of forwards? >
Actually, going back to typed lambda calculus, there is one well-defined definition: from the given integer to infinity away from zero. Since Ranges in Raku are always ordered in one direction (that is, Inf..-Inf is a void range, as is any range where the beginning is larger than the end), this definition is unimplementable, so it’s for the best that Range fails for Int:D. > >> >> Perplexed, >> -T >> >