Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 04:29 AM, Brian Duggan wrote: On Sunday, May 27, ToddAndMargo wrote: Why do I sometime see a range written `0..1000` and `0...1000` (three dots)? Two dots makes a Range. Three dots is the sequence operator -- it makes a Seq. ~ $ perl6 -e 'say (0..1000).^name'

Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
Hi All, What is wrong with this picture? Is my type being changed or are "Num" and "Rat" in a subset of "Real"? Also, what do I alter to get ^name to say real? $ p6 'my Real $x= 5e65; say $x.^name' Num $ p6 'my Real $x= 5.5; say $x.^name' Rat Many thanks, -T

Re: Real, Num, Rat question

2018-05-27 Thread Brandon Allbery
"Real" is a role (a collection of common methods reusable by multiple classes/types), not itself a class/type. Similarly, "Positional" is a role which provides common methods to "Array", "List", and "Seq" among others. On Sun, May 27, 2018 at 5:50 PM ToddAndMargo wrote: >

Re: Real, Num, Rat question

2018-05-27 Thread Brent Laabs
Real is a role, not a type. Both Num and Rat happen to do Real, so the type checking is ok. This would work OK with a type too -- you can safely store a Num in a `my Cool $foo` as well. You can't do anything to make the ^name method return Real. There are a few ways to check this, though. The

Re: my keeper on random numbers

2018-05-27 Thread Brian Duggan
On Sunday, May 27, ToddAndMargo wrote: > Why do I sometime see a range written `0..1000` > and `0...1000` (three dots)? Two dots makes a Range. Three dots is the sequence operator -- it makes a Seq. ~ $ perl6 -e 'say (0..1000).^name' Range ~ $ perl6 -e 'say

Re: my keeper on random numbers

2018-05-27 Thread Brian Duggan
On Sunday, May 27, ToddAndMargo wrote: > Hi Brian, > > `^name` is sweet. Why the caret? (I realize it won't work without it.) The caret is shorthand for .HOW.name(object), i.e. ~ $ perl6 -e 'say 12.^name' Int same thing: ~ $ perl6 -e 'say 12.HOW.name(12)'

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 03:42 PM, Brian Duggan wrote: On Sunday, May 27, ToddAndMargo wrote: Hi Brian, `^name` is sweet. Why the caret? (I realize it won't work without it.) The caret is shorthand for .HOW.name(object), i.e. ~ $ perl6 -e 'say 12.^name' Int same thing: ~ $

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On Sun, May 27, 2018 at 7:16 PM ToddAndMargo > wrote: On 05/27/2018 03:42 PM, Brian Duggan wrote: > ~ $ perl6 -e 'say 12.HOW.name (12)' > Int Does the "12" have to be repeated? On

Re: Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
On Sun, May 27, 2018 at 5:50 PM ToddAndMargo > wrote: Hi All, What is wrong with this picture? Is my type being changed or are "Num" and "Rat" in a subset of "Real"? Also, what do I alter to get ^name to say real?

Re: Real, Num, Rat question

2018-05-27 Thread ToddAndMargo
> On Sun, May 27, 2018 at 2:49 PM, ToddAndMargo > wrote: > > Hi All, > > What is wrong with this picture? Is my > type being changed or are "Num" and "Rat" in > a subset of "Real"? > > Also, what do I alter to get ^name

Re: my keeper on random numbers

2018-05-27 Thread ToddAndMargo
On 05/27/2018 03:42 PM, Brian Duggan wrote: ~ $ perl6 -e 'say 12.HOW.name(12)' Int Does the "12" have to be repeated?

Re: my keeper on random numbers

2018-05-27 Thread Brandon Allbery
In the long form, yes. That's why the ^ shorthand exists. With the long form you have to start from an object of the same type to get to its metamodel, then pass the object you're actually asking about to the metamodel method; the simplest way to do this is to reuse the same object. On Sun, May