Re: Please explain this to me

2018-09-16 Thread Brandon Allbery
Binding, iirc. You are binding a value directly instead of making a box to
assign it to.

On Mon, Sep 17, 2018 at 1:47 AM ToddAndMargo  wrote:

> >> On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo  >> > wrote:
> >>
> >> On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> >>  > Read this:
> >>  >
> >>
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/
> >>  >
> >>  > Then go back and read it again.  It took me several times, and
> >> I'm still
> >>  > not sure I get it all :)
> >>
> >> I am spacing on the difference between
> >>
> >>   my $foo  = 42; and
> >>   my $foo := 42;
> >>
> >> To add insult to injury, I come from Modula2, where
> >> `:=` is `=` in Perl.
> >>
> >> -T
>
>
> On 9/16/18 9:06 PM, Brandon Allbery wrote:
> > If you say "my $foo = 42", you are saying that $x is a box, and you are
> > putting 42 into it. You can put something else into that box later.
> >
> > If you say "my $foo := 42", you are saying that $x is 42 itself, not a
> > box containing 42. You can think of it as a constant of sorts. Because
> > it's not a box, you can't change what's in the nonexistent box later.
> >
> >  From here on it gets trickier, because there are things that can use
> > the box instead of what the box contains, notably Hash elements, and
> > which can then be changed by changing what's in the box directly instead
> > of by changing the Hash element.
> >
>
> Does `:=` have an official name?
>
> So, kind of like a constant you that can sometimes change.
>
> What would be the use of such?
>
>
> $ p6 'constant t=1.414; dd t;'
> 1.414
>
> $ p6 'my $t := 1.414; dd $t;'
> 1.414
>
> $ p6 'my $t := 1.414; $t += 1; dd $t;'
> Cannot assign to an immutable value
>in block  at -e line 1
>
> $ p6 'my $t := 1.414; $t := 4.14; dd $t;'
> 4.14
>
> $ p6 'my $t := 1.414; say $t + 9;'
> 10.414
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: Please explain this to me

2018-09-16 Thread Brad Gilbert
I think I have an idea of where your thinking is going wrong.
The trouble is going to be to describe it so that you can understand.

First, I think you may be misunderstanding what we mean by defined and
undefined.



So I will use "instance" and "class"

---

class Foo {};

say Foo;  # <- "class" value
say Foo.new(); # <- "instance" value

my $bar = Foo;   # <- "class" value
my $baz = Foo.new(); # <- "instance" value

Foo.defined.say;  # False  # <- "class" value
Foo.new().defined.say; # True  # <- "instance" value

---

In Perl 6 types are both types, and values:

You can store it as a value.

my $a = Int;

I am going to call that a "class" value.

In this example the value is of type "Int".

The "Int" ("class") value is also of type "Int".

You can even pass around "class" values with the type "smiley".

my $a = Int:D;

This is useful in the compiler.

---

If you use it as a type:

my Int $b;

You are saying that it must be an "instance" or a "class" value of that type.

The default value is the same as the type.

So that last example is the same as:

my Int $b = Int;

You can bring it back to the default by assigning a "class" value.

$b = 42;
$b = Int;

If you use a type "smiley" in the type, you constrain it further.

my Int:D $c;  # error

In this case you are saying only "instance" values are allowed.

In that last case the default value is "Int:D", which is a "class"
value, but only "instance" values are allowed by the type.

Note that again the default value is the same as the type, so it
produces an error.

---

The type/value "Nil" is special, as it changes the variable to it's default.

my Int $d is default(42);   # 42
$d = 10;# 10
$d = Nil;   # 42

In this example for it to hold a "class" value, you have to do so explicitly.

   $d = Int;   # Int

---

my Int:U $u;

The "class" values that can be stored in this variable are below

Int
Int:_ # same as previous
Int:U
Int:D

class Other-Int is Int {…}
Other-Int
Other-Int:_ # same as previous
Other-Int:U
Other-Int:D

my \foo = Int but 'Foo'
foo
foo:_ # same as previous
foo:U
foo:D

Note again that I am talking about them as values.

---

When you use a type in a declaration:

my Int $f;

You can think about it as a macro named "my" which takes two arguments.
The first one is a "class" value, and the second one is the name of
the variable.

This makes it so that you can have aliases.

constant Name = Str:D;

my Name $first-name = "Brad";

---

I think where you are going wrong is that other languages also use the
words "defined" and "undefined".

When we use them in Perl 6, we mean something slightly different.

===

You just added a question about :=

:= is the binding operator.

Normally scalar variables store a Scalar that you assign into.

Just think about this:

my $a = 0;

As being short for something like the following fake code:

(my $a := Scalar.new) = 0;

When you use :=, you are basically creating an alias:

my $b;
my $c := $b;

$c = 42;
say $b;  # 42

This also means that if you alias a value, the variable becomes readonly

my $d := 0;
$d = 0;  # error Cannot assign to an immutable value
On Sun, Sep 16, 2018 at 7:49 PM ToddAndMargo  wrote:
>
> On 09/14/2018 08:07 PM, ToddAndMargo wrote:
> > ":D"
> >  means it wants actual data in the string and not a Nil.
> >  The jargon for this requirement is that is is constrained
> >  to an actual value
> >
> >  If it wanted a Nil, it would say ":U" or constrained to
> >  a Nil
>
> Iteration 3:
>
>
> ":D"
>  means it wants the variable "Defined" (Constrained).
>  For example:
>my Str $x;
>my Int $i;
>
>  The value of the variable may be empty but the variable
>  does not become "defined" until a value is places in it.
>  ("Nil" is seen as "Undefined")
>
> ":U"
>  means the variable is "Undefined" (defaults to type "Any")
>
>  For example:
>my $x;
>my $i;
>
>
>
> $ p6 'my $x; if $x.defined {say "Defined"}else{say "Undefined"};'
> Undefined
>
> $ p6 'my Real $x; if $x.defined {say "Defined"}else{say "Undefined"};'
> Undefined
>
> $ p6 'my Real $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
> Defined
>
> $ p6 'my $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
> Defined
>
>
> $ p6 'my $x=3; dd $x'
> Int $x = 3
>
> $ p6 'my $x; dd $x'
> Any $x = Any
>
> $ p6 'my Real $x; dd $x'
> Real $x = Real
>
> $ p6 'my Real $x = 3; dd $x'
> Int $x = 3
>
> Huh ??


Re: Rat

2018-09-16 Thread ToddAndMargo

On 9/16/18 7:37 PM, Curt Tilmes wrote:

Rat is a type (a 'class').

It is also a method on class Numeric.  You can take anything Numeric, 
and call .Rat() on it to get an equivalent Rat (well, within $epsilon)


You can't, for example, say
my Rat $x = pi;
Since pi is not rational -- it won't fit in that box.
You can, however, ask pi to turn itself into a Rat (or something pretty 
close), then it will fit.

my Rat $x = pi.Rat;


Hi Curt,

I just wrapped my brain around "Role" (Real) being
a superset of "Class" (Rat).  When you tell somethig
it isa Rol, it can take on any of the clasees in its subset.
If yo want somethinbg specific, use a class.

And now I understand.

Thank you,
-T

Just out of curiosity, how does Perl handle an
irrational number, like pi or the square root of two?
A number that keeps going on and on and on ...

As an engineer, it is all about significance.  1.0
is not the same as 1.00 to an engineer.  So
we don't care about run on numbers.  We just
use the significant part.


Re: Rat

2018-09-16 Thread ToddAndMargo

On 9/16/18 7:34 PM, Vadim Belman wrote:

You're messing up a type and a method to convert into that type. For example,

dd "1.2".Rat

will output you a rational whereas

dd "1.2"

will output a string.

Again, search for Rat on docs gives you a line just under the Class section.



I had to learn the difference between a "role" and a "class".
Now I understand.

Thank you!


Re: Please explain this to me

2018-09-16 Thread ToddAndMargo
On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo > wrote:


On 09/16/2018 05:58 PM, Curt Tilmes wrote:
 > Read this:
 >

https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/
 >
 > Then go back and read it again.  It took me several times, and
I'm still
 > not sure I get it all :)

I am spacing on the difference between

  my $foo  = 42; and
  my $foo := 42;

To add insult to injury, I come from Modula2, where
`:=` is `=` in Perl.

-T



On 9/16/18 9:06 PM, Brandon Allbery wrote:
If you say "my $foo = 42", you are saying that $x is a box, and you are 
putting 42 into it. You can put something else into that box later.


If you say "my $foo := 42", you are saying that $x is 42 itself, not a 
box containing 42. You can think of it as a constant of sorts. Because 
it's not a box, you can't change what's in the nonexistent box later.


 From here on it gets trickier, because there are things that can use 
the box instead of what the box contains, notably Hash elements, and 
which can then be changed by changing what's in the box directly instead 
of by changing the Hash element.




Does `:=` have an official name?

So, kind of like a constant you that can sometimes change.

What would be the use of such?


$ p6 'constant t=1.414; dd t;'
1.414

$ p6 'my $t := 1.414; dd $t;'
1.414

$ p6 'my $t := 1.414; $t += 1; dd $t;'
Cannot assign to an immutable value
  in block  at -e line 1

$ p6 'my $t := 1.414; $t := 4.14; dd $t;'
4.14

$ p6 'my $t := 1.414; say $t + 9;'
10.414


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 9/16/18 8:59 PM, Brandon Allbery wrote:
Also, going by math calling the "real numbers" misses that math treats 
integers as a subset of real numbers; there is no hard distinction 
between them in math. Computers need hard distinctions here because 
integral, rational, and floating point numbers must be stored in 
different ways, unless they take the PHP / Javascript solution (storing 
them all as strings or floating point, respectively). Perl 6's Real is a 
role that the actual types "does" if they are compatible with it.


If you want to do the Perl 5-ish thing where it hid the differences (and 
sometimes promoted an integral value to floating without asking, never 
to return), use the Real role as a type to hide the difference between 
them. If you want to be specific, use the correct type.



Got it.  A "Role" is a superset of "types"


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 9/16/18 9:10 PM, Brandon Allbery wrote:
Sort of. A role is a "package" of components available to build classes 
from. This allows someone to write a sub or method that works for any 
kind of number by using the role instead of having to write the same 
thing over and over for every numeric class, or every class representing 
a non-complex number, etc. There is similarly a role packaging up 
various operations common to all string-like types, called Stringy.



The light bulb went off.  Thank you!


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 9/16/18 9:02 PM, ToddAndMargo wrote:

On 9/16/18 8:51 PM, Brandon Allbery wrote:
You're assuming "Real" means "a float of some kind". It's not; it 
defines all the operations in common over non-Complex numbers (Int, 
Rat, Num, etc.). What you are looking for, Perl 6 calls Num.


https://docs.perl6.org/type.html:
    Real role Non-complex number

https://en.wikipedia.org/wiki/Real_number

  In mathematics, a real number is a value of a continuous
  quantity that can represent a distance along a line. The
  adjective real in this context was introduced in the 17th
  century by René Descartes, who distinguished between real
  and imaginary roots of polynomials. The real numbers
  include all the rational numbers, such as the integer −5
  and the fraction 4/3, and all the irrational numbers, such
  as √2 (1.41421356..., the square root of 2, an irrational
  algebraic number). Included within the irrationals are
  the transcendental numbers, such as π (3.14159265...). In
  addition to measuring distance, real numbers can be used
  to measure quantities such as time, mass, energy, velocity,
  and many more.

So Rat is a subset of Real.

And if I want something specific, I have to call out
a "class", not a "Role".  A "Role" is a superset of "classes".
And I will get the proper class picked out of the subsets
when I assign something to the variable.  I will only
throw an error is I asn something that is not in tne subsets.

     Rat    class Rational number (limited-precision)

Okay, class dismissed.

Thank you.  You guys have been very patient with me.

-T


I just posted:

RFE: please list the subsets for Real
https://github.com/perl6/doc/issues/2315


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
Sort of. A role is a "package" of components available to build classes
from. This allows someone to write a sub or method that works for any kind
of number by using the role instead of having to write the same thing over
and over for every numeric class, or every class representing a non-complex
number, etc. There is similarly a role packaging up various operations
common to all string-like types, called Stringy.

On Mon, Sep 17, 2018 at 12:03 AM ToddAndMargo  wrote:

> On 9/16/18 8:51 PM, Brandon Allbery wrote:
> > You're assuming "Real" means "a float of some kind". It's not; it
> > defines all the operations in common over non-Complex numbers (Int, Rat,
> > Num, etc.). What you are looking for, Perl 6 calls Num.
>
> https://docs.perl6.org/type.html:
> RealroleNon-complex number
>
> https://en.wikipedia.org/wiki/Real_number
>
>   In mathematics, a real number is a value of a continuous
>   quantity that can represent a distance along a line. The
>   adjective real in this context was introduced in the 17th
>   century by René Descartes, who distinguished between real
>   and imaginary roots of polynomials. The real numbers
>   include all the rational numbers, such as the integer −5
>   and the fraction 4/3, and all the irrational numbers, such
>   as √2 (1.41421356..., the square root of 2, an irrational
>   algebraic number). Included within the irrationals are
>   the transcendental numbers, such as π (3.14159265...). In
>   addition to measuring distance, real numbers can be used
>   to measure quantities such as time, mass, energy, velocity,
>   and many more.
>
> So Rat is a subset of Real.
>
> And if I want something specific, I have to call out
> a "class", not a "Role".  A "Role" is a superset of "classes".
> And I will get the proper class picked out of the subsets
> when I assign something to the variable.  I will only
> throw an error is I asn something that is not in tne subsets.
>
>  Ratclass Rational number (limited-precision)
>
> Okay, class dismissed.
>
> Thank you.  You guys have been very patient with me.
>
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: Please explain this to me

2018-09-16 Thread Brandon Allbery
If you say "my $foo = 42", you are saying that $x is a box, and you are
putting 42 into it. You can put something else into that box later.

If you say "my $foo := 42", you are saying that $x is 42 itself, not a box
containing 42. You can think of it as a constant of sorts. Because it's not
a box, you can't change what's in the nonexistent box later.

>From here on it gets trickier, because there are things that can use the
box instead of what the box contains, notably Hash elements, and which can
then be changed by changing what's in the box directly instead of by
changing the Hash element.

On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo  wrote:

> On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> > Read this:
> >
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/
> >
> > Then go back and read it again.  It took me several times, and I'm still
> > not sure I get it all :)
>
> I am spacing on the difference between
>
>  my $foo  = 42; and
>  my $foo := 42;
>
> To add insult to injury, I come from Modula2, where
> `:=` is `=` in Perl.
>
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 9/16/18 8:51 PM, Brandon Allbery wrote:
You're assuming "Real" means "a float of some kind". It's not; it 
defines all the operations in common over non-Complex numbers (Int, Rat, 
Num, etc.). What you are looking for, Perl 6 calls Num.


https://docs.perl6.org/type.html:
   Real roleNon-complex number

https://en.wikipedia.org/wiki/Real_number

 In mathematics, a real number is a value of a continuous
 quantity that can represent a distance along a line. The
 adjective real in this context was introduced in the 17th
 century by René Descartes, who distinguished between real
 and imaginary roots of polynomials. The real numbers
 include all the rational numbers, such as the integer −5
 and the fraction 4/3, and all the irrational numbers, such
 as √2 (1.41421356..., the square root of 2, an irrational
 algebraic number). Included within the irrationals are
 the transcendental numbers, such as π (3.14159265...). In
 addition to measuring distance, real numbers can be used
 to measure quantities such as time, mass, energy, velocity,
 and many more.

So Rat is a subset of Real.

And if I want something specific, I have to call out
a "class", not a "Role".  A "Role" is a superset of "classes".
And I will get the proper class picked out of the subsets
when I assign something to the variable.  I will only
throw an error is I asn something that is not in tne subsets.

Rat class Rational number (limited-precision)

Okay, class dismissed.

Thank you.  You guys have been very patient with me.

-T


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
Also, going by math calling the "real numbers" misses that math treats
integers as a subset of real numbers; there is no hard distinction between
them in math. Computers need hard distinctions here because integral,
rational, and floating point numbers must be stored in different ways,
unless they take the PHP / Javascript solution (storing them all as strings
or floating point, respectively). Perl 6's Real is a role that the actual
types "does" if they are compatible with it.

If you want to do the Perl 5-ish thing where it hid the differences (and
sometimes promoted an integral value to floating without asking, never to
return), use the Real role as a type to hide the difference between them.
If you want to be specific, use the correct type.

On Sun, Sep 16, 2018 at 11:51 PM Brandon Allbery 
wrote:

> You're assuming "Real" means "a float of some kind". It's not; it defines
> all the operations in common over non-Complex numbers (Int, Rat, Num,
> etc.). What you are looking for, Perl 6 calls Num.
>
> On Sun, Sep 16, 2018 at 8:53 PM ToddAndMargo 
> wrote:
>
>> Hi All,
>>
>> I am confused, again:
>>
>>
>> $ p6 'my $x=3; dd $x'
>> Int $x = 3
>> Makes sense
>>
>>
>> $ p6 'my $x; dd $x'
>> Any $x = Any
>> Makes Sense
>>
>> $ p6 'my Real $x; dd $x'
>> Real $x = Real
>> makes sense
>>
>> $ p6 'my Real $x = 3; dd $x'
>> Int $x = 3
>> What  Integer ?  Did I or did I not just tell it
>> is was a "Real" ?
>>
>> :'(
>>
>> -T
>>
>
>
> --
> brandon s allbery kf8nh
> allber...@gmail.com
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
You're assuming "Real" means "a float of some kind". It's not; it defines
all the operations in common over non-Complex numbers (Int, Rat, Num,
etc.). What you are looking for, Perl 6 calls Num.

On Sun, Sep 16, 2018 at 8:53 PM ToddAndMargo  wrote:

> Hi All,
>
> I am confused, again:
>
>
> $ p6 'my $x=3; dd $x'
> Int $x = 3
> Makes sense
>
>
> $ p6 'my $x; dd $x'
> Any $x = Any
> Makes Sense
>
> $ p6 'my Real $x; dd $x'
> Real $x = Real
> makes sense
>
> $ p6 'my Real $x = 3; dd $x'
> Int $x = 3
> What  Integer ?  Did I or did I not just tell it
> is was a "Real" ?
>
> :'(
>
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: metamorphosis or alchemy?

2018-09-16 Thread Vadim Belman
Actually what I meant was

my Real $x = 3; $x = Nil; $x.WHO.say

What you must read undoubtedly are this: 
https://docs.perl6.org/language/containers 
 and this: 
https://opensource.com/article/18/8/containers-perl-6 


> 16 вер. 2018 р. о 22:31 ToddAndMargo  написав(ла):
> 
 16 вер. 2018 р. о 22:11 Curt Tilmes >>> > написав(ла):
 
 It isn't changing anything.
 
 You've still got a box ('container') that can only hold something 'Real'.
 
 You just happen to have a value in that box that is a 'Rat'.
 
 It is perfectly fine to put a Rat value in a Real box, because a Rat is 
 also a Real (does the 'Real' role).
 
 You can still stick some other Real in the box, and you still can't stick 
 anything that isn't a Real in the box.
 
 
 
 On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo >>> > wrote:
 
On 09/16/2018 06:50 PM, Curt Tilmes wrote:
> Note that an object that is a Rat also does Real (see
> https://docs.perl6.org/type/Rat#Type_Graph)
>
> say Rat ~~ Real
>
> True
>
> Your're making a box that takes a Real, then putting a Rat (that
also does Real) into that box.
>
> It then says "yes, you've got a Rat in there".
>
>
 
Why is it changing thing on the fly when I tell it not to?
I claim foul !!AA HHH !!!
 
>>> Best regards,
>>> Vadim Belman
> 
> On 09/16/2018 07:18 PM, Vadim Belman wrote:
>> I would add on top of Curt's explanation. Try assigning Nil to $x and then 
>> ask for its type. You'll get your Real back!
> 
> 
> 
> I am see it but I am not seeing your point:
> 
> $ p6 'my Real $x= Nil; dd $x;'
> Real $x = Real
> 
> $ p6 'my Real $x= Nil; $x = 3.1415; dd $x;'
> Rat $x = 3.1415
> 
> Why is it changing the type on the fly after
> I defined it?
> 

Best regards,
Vadim Belman



Re: Rat

2018-09-16 Thread Curt Tilmes
Rat is a type (a 'class').

It is also a method on class Numeric.  You can take anything Numeric, and
call .Rat() on it to get an equivalent Rat (well, within $epsilon)

You can't, for example, say
my Rat $x = pi;
Since pi is not rational -- it won't fit in that box.
You can, however, ask pi to turn itself into a Rat (or something pretty
close), then it will fit.
my Rat $x = pi.Rat;


On Sun, Sep 16, 2018 at 10:29 PM ToddAndMargo  wrote:

> Hi All,
>
> What in the world are they trying to say here?
>
> https://docs.perl6.org/routine/Rat
>  (Numeric) method Rat
>
>  method Rat(Numeric:D: Real $epsilon = 1.0e-6 --> Rat:D)
>
>  If this Numeric is equivalent to a Real, return a Rat which
>  is within $epsilon of that Real's value. Fail
>  with X::Numeric::Real otherwise.
>
> And is this why I can not find a type "Rat"?  Because
> it is a method?
>
> Then why does
>  $ p6 'my Real $x; $x = 3.1415; dd $x;'
>  Rat $x = 3.1415
> say it is a type "Rat"?
>
>
> Yours in confusion,
> -T
>


Re: Rat

2018-09-16 Thread Vadim Belman
You're messing up a type and a method to convert into that type. For example, 

dd "1.2".Rat

will output you a rational whereas 

dd "1.2"

will output a string.

Again, search for Rat on docs gives you a line just under the Class section. 

> 16 вер. 2018 р. о 22:29 ToddAndMargo  написав(ла):
> 
> Hi All,
> 
> What in the world are they trying to say here?
> 
> https://docs.perl6.org/routine/Rat
>(Numeric) method Rat
> 
>method Rat(Numeric:D: Real $epsilon = 1.0e-6 --> Rat:D)
> 
>If this Numeric is equivalent to a Real, return a Rat which
>is within $epsilon of that Real's value. Fail
>with X::Numeric::Real otherwise.
> 
> And is this why I can not find a type "Rat"?  Because
> it is a method?
> 
> Then why does
>$ p6 'my Real $x; $x = 3.1415; dd $x;'
>Rat $x = 3.1415
> say it is a type "Rat"?
> 
> 
> Yours in confusion,
> -T
> 

Best regards,
Vadim Belman


Re: metamorphosis or alchemy?

2018-09-16 Thread Curt Tilmes
Note that 'dd' is not part of Perl 6.  It is a Rakudo enhancement.  (I
agree it should be documented, but some disagree..)

dd is describing the value, not the container.

it is describing the value you've got in the container, not the container.

You can use ".VAR" to check out the container instead of the value:

my Real $x;# Make a box that can only hold something 'Real'
$x = 3.14;   # 3.14 is a Rat, which is also Real, so it will fit in
the box.
dd $x; # Rat $x = 3.14, a description of the value in the
box.
say $x.VAR.of;# (Real) -- The box can hold anything that is Real
(which includes Rats)


On Sun, Sep 16, 2018 at 10:20 PM ToddAndMargo  wrote:

> >> On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo  >> > wrote:
> >>
> >> On 09/16/2018 06:50 PM, Curt Tilmes wrote:
> >>  > Note that an object that is a Rat also does Real (see
> >>  > https://docs.perl6.org/type/Rat#Type_Graph)
> >>  >
> >>  > say Rat ~~ Real
> >>  >
> >>  > True
> >>  >
> >>  > Your're making a box that takes a Real, then putting a Rat (that
> >> also does Real) into that box.
> >>  >
> >>  > It then says "yes, you've got a Rat in there".
> >>  >
> >>  >
> >>
> >> Why is it changing thing on the fly when I tell it not to?
> >> I claim foul !!AA HHH !!!
> >>
>
> On 09/16/2018 07:11 PM, Curt Tilmes wrote:
> > It isn't changing anything.
> >
> > You've still got a box ('container') that can only hold something 'Real'.
> >
> > You just happen to have a value in that box that is a 'Rat'.
> >
> > It is perfectly fine to put a Rat value in a Real box, because a Rat is
> > also a Real (does the 'Real' role).
> >
> > You can still stick some other Real in the box, and you still can't
> > stick anything that isn't a Real in the box.
> >
> >
> >
>
>
> So it is "dd"'s doing.
>
>
> https://docs.perl6.org/routine/dd
> 404: Page Not Found
>
> Search does not work either.
>
>  
>
>
> I just added:
> RFE: dd in the docs
> https://github.com/perl6/doc/issues/2314
>
> Is it just me, or am I the only one does the RTFM thing !!??
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo
16 вер. 2018 р. о 22:11 Curt Tilmes > написав(ла):


It isn't changing anything.

You've still got a box ('container') that can only hold something 'Real'.

You just happen to have a value in that box that is a 'Rat'.

It is perfectly fine to put a Rat value in a Real box, because a Rat 
is also a Real (does the 'Real' role).


You can still stick some other Real in the box, and you still can't 
stick anything that isn't a Real in the box.




On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo > wrote:


On 09/16/2018 06:50 PM, Curt Tilmes wrote:
> Note that an object that is a Rat also does Real (see
> https://docs.perl6.org/type/Rat#Type_Graph)
>
> say Rat ~~ Real
>
> True
>
> Your're making a box that takes a Real, then putting a Rat (that
also does Real) into that box.
>
> It then says "yes, you've got a Rat in there".
>
>

Why is it changing thing on the fly when I tell it not to?
I claim foul !!AA HHH !!!



Best regards,
Vadim Belman



On 09/16/2018 07:18 PM, Vadim Belman wrote:
I would add on top of Curt's explanation. Try assigning Nil to $x and 
then ask for its type. You'll get your Real back!






I am see it but I am not seeing your point:

$ p6 'my Real $x= Nil; dd $x;'
Real $x = Real

$ p6 'my Real $x= Nil; $x = 3.1415; dd $x;'
Rat $x = 3.1415

Why is it changing the type on the fly after
I defined it?


Rat

2018-09-16 Thread ToddAndMargo

Hi All,

What in the world are they trying to say here?

https://docs.perl6.org/routine/Rat
(Numeric) method Rat

method Rat(Numeric:D: Real $epsilon = 1.0e-6 --> Rat:D)

If this Numeric is equivalent to a Real, return a Rat which
is within $epsilon of that Real's value. Fail
with X::Numeric::Real otherwise.

And is this why I can not find a type "Rat"?  Because
it is a method?

Then why does
$ p6 'my Real $x; $x = 3.1415; dd $x;'
Rat $x = 3.1415
say it is a type "Rat"?


Yours in confusion,
-T


Re: metamorphosis or alchemy?

2018-09-16 Thread Vadim Belman
Actually, typing 'dd' in the searchbox on docs.perl6.org 
 gives you a long list with dd in 'Reference' section 
of that list.

> 
> https://docs.perl6.org/routine/dd
> 404: Page Not Found
> 
> Search does not work either.
> 

Best regards,
Vadim Belman



Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo
On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo > wrote:


On 09/16/2018 06:50 PM, Curt Tilmes wrote:
 > Note that an object that is a Rat also does Real (see
 > https://docs.perl6.org/type/Rat#Type_Graph)
 >
 > say Rat ~~ Real
 >
 > True
 >
 > Your're making a box that takes a Real, then putting a Rat (that
also does Real) into that box.
 >
 > It then says "yes, you've got a Rat in there".
 >
 >

Why is it changing thing on the fly when I tell it not to?
I claim foul !!AA HHH !!!



On 09/16/2018 07:11 PM, Curt Tilmes wrote:

It isn't changing anything.

You've still got a box ('container') that can only hold something 'Real'.

You just happen to have a value in that box that is a 'Rat'.

It is perfectly fine to put a Rat value in a Real box, because a Rat is 
also a Real (does the 'Real' role).


You can still stick some other Real in the box, and you still can't 
stick anything that isn't a Real in the box.







So it is "dd"'s doing.


https://docs.perl6.org/routine/dd
404: Page Not Found

Search does not work either.

 


I just added:
   RFE: dd in the docs
   https://github.com/perl6/doc/issues/2314

Is it just me, or am I the only one does the RTFM thing !!??


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: metamorphosis or alchemy?

2018-09-16 Thread Vadim Belman
I would add on top of Curt's explanation. Try assigning Nil to $x and then ask 
for its type. You'll get your Real back!

> 16 вер. 2018 р. о 22:11 Curt Tilmes  написав(ла):
> 
> It isn't changing anything.
> 
> You've still got a box ('container') that can only hold something 'Real'.
> 
> You just happen to have a value in that box that is a 'Rat'.
> 
> It is perfectly fine to put a Rat value in a Real box, because a Rat is also 
> a Real (does the 'Real' role).
> 
> You can still stick some other Real in the box, and you still can't stick 
> anything that isn't a Real in the box.
> 
> 
> 
> On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo  > wrote:
> On 09/16/2018 06:50 PM, Curt Tilmes wrote:
> > Note that an object that is a Rat also does Real (see 
> > https://docs.perl6.org/type/Rat#Type_Graph 
> > )
> > 
> > say Rat ~~ Real
> > 
> > True
> > 
> > Your're making a box that takes a Real, then putting a Rat (that also does 
> > Real) into that box.
> > 
> > It then says "yes, you've got a Rat in there".
> > 
> > 
> 
> Why is it changing thing on the fly when I tell it not to?
> I claim foul !!AA HHH !!!

Best regards,
Vadim Belman



Re: metamorphosis or alchemy?

2018-09-16 Thread Curt Tilmes
It isn't changing anything.

You've still got a box ('container') that can only hold something 'Real'.

You just happen to have a value in that box that is a 'Rat'.

It is perfectly fine to put a Rat value in a Real box, because a Rat is
also a Real (does the 'Real' role).

You can still stick some other Real in the box, and you still can't stick
anything that isn't a Real in the box.



On Sun, Sep 16, 2018 at 10:07 PM ToddAndMargo  wrote:

> On 09/16/2018 06:50 PM, Curt Tilmes wrote:
> > Note that an object that is a Rat also does Real (see
> > https://docs.perl6.org/type/Rat#Type_Graph)
> >
> > say Rat ~~ Real
> >
> > True
> >
> > Your're making a box that takes a Real, then putting a Rat (that also
> does Real) into that box.
> >
> > It then says "yes, you've got a Rat in there".
> >
> >
>
> Why is it changing thing on the fly when I tell it not to?
> I claim foul !!AA HHH !!!
>


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 09/16/2018 06:50 PM, Curt Tilmes wrote:
Note that an object that is a Rat also does Real (see 
https://docs.perl6.org/type/Rat#Type_Graph)


say Rat ~~ Real

True

Your're making a box that takes a Real, then putting a Rat (that also does 
Real) into that box.

It then says "yes, you've got a Rat in there".




Why is it changing thing on the fly when I tell it not to?
I claim foul !!AA HHH !!!


Re: Please explain this to me

2018-09-16 Thread ToddAndMargo

On 09/16/2018 06:41 PM, ToddAndMargo wrote:

Hi Mark,

I am sorry, but books don't work for me.  Manuals do.
And correspondences do too.   That is just the way my
brain works. And, yes, I know I am weird.

-T


Videos don't work either.  When I am forced to watch
one to figure something out (Inkscape), I nearly
go insane.  And my mother would wash my mouth out
with soap.


RE: Please explain this to me

2018-09-16 Thread Mark Devine
I get it.  Different angles of approach.  Some methods don't make a dent with 
me (I.e. rote).

Mark

-Original Message-
From: ToddAndMargo  
Sent: Sunday, September 16, 2018 21:42
To: perl6-users@perl.org
Subject: Re: Please explain this to me

On 09/16/2018 06:23 PM, Mark Devine wrote:
> foy, brian d. Learning Perl 6: Keeping the Easy, Hard, and Impossible Within 
> Reach (Kindle Location 557). O'Reilly Media. Kindle Edition.
> 
> Chapter 2: Binding and Assignment: "There’s an important concept here that 
> you should learn early."  [[ what follows in the most concise and 
> understandable explanation that I have found yet to the question you raised ]]
> 
> As I'm going through Learning Perl 6, he's really done a fantastic job of 
> answering tons of the questions that I've been tracking in this mailing list. 
>  Uncanny really.  The author rolls the angles just right and I'm having 
> mini-epiphanies one after another.
> 
> So recommended...
> 
> Mark

Hi Mark,

I am sorry, but books don't work for me.  Manuals do.
And correspondences do too.   That is just the way my
brain works. And, yes, I know I am weird.

-T


Re: metamorphosis or alchemy?

2018-09-16 Thread Curt Tilmes
Note that an object that is a Rat also does Real (see
https://docs.perl6.org/type/Rat#Type_Graph)

say Rat ~~ Real

True

Your're making a box that takes a Real, then putting a Rat (that also
does Real) into that box.

It then says "yes, you've got a Rat in there".



On Sun, Sep 16, 2018 at 9:35 PM ToddAndMargo  wrote:

> On 09/16/2018 05:52 PM, ToddAndMargo wrote:
> > Hi All,
> >
> > I am confused, again:
> >
> >
> > $ p6 'my $x=3; dd $x'
> > Int $x = 3
> > Makes sense
> >
> >
> > $ p6 'my $x; dd $x'
> > Any $x = Any
> > Makes Sense
> >
> > $ p6 'my Real $x; dd $x'
> > Real $x = Real
> > makes sense
> >
> > $ p6 'my Real $x = 3; dd $x'
> > Int $x = 3
> > What  Integer ?  Did I or did I not just tell it
> > is was a "Real" ?
> >
> > :'(
> >
> > -T
>
>
> The plot thickens:
>
> $ p6 'my Real $x; $x = "abc"; dd $x'
> Type check failed in assignment to $x; expected Real but got Str ("abc")
>in block  at -e line 1
>
> This is what I expected
>
>
> $ p6 'my Real $x; $x = 3; dd $x; say $x.perl'
> Int $x = 3
> 3
>
> Not what I expected
>
>
> $ p6 'my Real $x; $x = 3.1415; dd $x; say $x.perl'
> Rat $x = 3.1415
> 3.1415
>
> Huh?  Now is it a "Rational number".
>
>
> AA H !!
>


Re: Please explain this to me

2018-09-16 Thread ToddAndMargo

On 09/16/2018 06:23 PM, Mark Devine wrote:

foy, brian d. Learning Perl 6: Keeping the Easy, Hard, and Impossible Within 
Reach (Kindle Location 557). O'Reilly Media. Kindle Edition.

Chapter 2: Binding and Assignment: "There’s an important concept here that you 
should learn early."  [[ what follows in the most concise and understandable 
explanation that I have found yet to the question you raised ]]

As I'm going through Learning Perl 6, he's really done a fantastic job of 
answering tons of the questions that I've been tracking in this mailing list.  
Uncanny really.  The author rolls the angles just right and I'm having 
mini-epiphanies one after another.

So recommended...

Mark


Hi Mark,

I am sorry, but books don't work for me.  Manuals do.
And correspondences do too.   That is just the way my
brain works. And, yes, I know I am weird.

-T


Re: metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

On 09/16/2018 05:52 PM, ToddAndMargo wrote:

Hi All,

I am confused, again:


$ p6 'my $x=3; dd $x'
Int $x = 3
Makes sense


$ p6 'my $x; dd $x'
Any $x = Any
Makes Sense

$ p6 'my Real $x; dd $x'
Real $x = Real
makes sense

$ p6 'my Real $x = 3; dd $x'
Int $x = 3
What  Integer ?  Did I or did I not just tell it
is was a "Real" ?

:'(

-T



The plot thickens:

$ p6 'my Real $x; $x = "abc"; dd $x'
Type check failed in assignment to $x; expected Real but got Str ("abc")
  in block  at -e line 1

This is what I expected


$ p6 'my Real $x; $x = 3; dd $x; say $x.perl'
Int $x = 3
3

Not what I expected


$ p6 'my Real $x; $x = 3.1415; dd $x; say $x.perl'
Rat $x = 3.1415
3.1415

Huh?  Now is it a "Rational number".


AA H !!


RE: Please explain this to me

2018-09-16 Thread Mark Devine
foy, brian d. Learning Perl 6: Keeping the Easy, Hard, and Impossible Within 
Reach (Kindle Location 557). O'Reilly Media. Kindle Edition.

Chapter 2: Binding and Assignment: "There’s an important concept here that you 
should learn early."  [[ what follows in the most concise and understandable 
explanation that I have found yet to the question you raised ]]

As I'm going through Learning Perl 6, he's really done a fantastic job of 
answering tons of the questions that I've been tracking in this mailing list.  
Uncanny really.  The author rolls the angles just right and I'm having 
mini-epiphanies one after another.

So recommended...

Mark

-Original Message-
From: ToddAndMargo  
Sent: Sunday, September 16, 2018 21:02
To: perl6-users@perl.org
Subject: Re: Please explain this to me

On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> Read this:
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-a
> nd-containers/
> 
> Then go back and read it again.  It took me several times, and I'm 
> still not sure I get it all :)

I am spacing on the difference between

 my $foo  = 42; and
 my $foo := 42;

To add insult to injury, I come from Modula2, where `:=` is `=` in Perl.

-T


Re: Please explain this to me

2018-09-16 Thread ToddAndMargo

On 09/16/2018 05:58 PM, Curt Tilmes wrote:

Read this:
https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/

Then go back and read it again.  It took me several times, and I'm still 
not sure I get it all :)


I am spacing on the difference between

my $foo  = 42; and
my $foo := 42;

To add insult to injury, I come from Modula2, where
`:=` is `=` in Perl.

-T


Re: Please explain this to me

2018-09-16 Thread Curt Tilmes
Read this:
https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/

Then go back and read it again.  It took me several times, and I'm still
not sure I get it all :)


On Sun, Sep 16, 2018 at 8:49 PM ToddAndMargo  wrote:

> On 09/14/2018 08:07 PM, ToddAndMargo wrote:
> > ":D"
> >  means it wants actual data in the string and not a Nil.
> >  The jargon for this requirement is that is is constrained
> >  to an actual value
> >
> >  If it wanted a Nil, it would say ":U" or constrained to
> >  a Nil
>
> Iteration 3:
>
>
> ":D"
>  means it wants the variable "Defined" (Constrained).
>  For example:
>my Str $x;
>my Int $i;
>
>  The value of the variable may be empty but the variable
>  does not become "defined" until a value is places in it.
>  ("Nil" is seen as "Undefined")
>
> ":U"
>  means the variable is "Undefined" (defaults to type "Any")
>
>  For example:
>my $x;
>my $i;
>
>
>
> $ p6 'my $x; if $x.defined {say "Defined"}else{say "Undefined"};'
> Undefined
>
> $ p6 'my Real $x; if $x.defined {say "Defined"}else{say "Undefined"};'
> Undefined
>
> $ p6 'my Real $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
> Defined
>
> $ p6 'my $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
> Defined
>
>
> $ p6 'my $x=3; dd $x'
> Int $x = 3
>
> $ p6 'my $x; dd $x'
> Any $x = Any
>
> $ p6 'my Real $x; dd $x'
> Real $x = Real
>
> $ p6 'my Real $x = 3; dd $x'
> Int $x = 3
>
> Huh ??
>


metamorphosis or alchemy?

2018-09-16 Thread ToddAndMargo

Hi All,

I am confused, again:


$ p6 'my $x=3; dd $x'
Int $x = 3
Makes sense


$ p6 'my $x; dd $x'
Any $x = Any
Makes Sense

$ p6 'my Real $x; dd $x'
Real $x = Real
makes sense

$ p6 'my Real $x = 3; dd $x'
Int $x = 3
What  Integer ?  Did I or did I not just tell it
is was a "Real" ?

:'(

-T


Re: Please explain this to me

2018-09-16 Thread ToddAndMargo

On 09/14/2018 08:07 PM, ToddAndMargo wrote:

":D"
     means it wants actual data in the string and not a Nil.
     The jargon for this requirement is that is is constrained
     to an actual value

     If it wanted a Nil, it would say ":U" or constrained to
     a Nil


Iteration 3:


":D"
means it wants the variable "Defined" (Constrained).
For example:
  my Str $x;
  my Int $i;

The value of the variable may be empty but the variable
does not become "defined" until a value is places in it.
("Nil" is seen as "Undefined")

":U"
means the variable is "Undefined" (defaults to type "Any")

For example:
  my $x;
  my $i;



$ p6 'my $x; if $x.defined {say "Defined"}else{say "Undefined"};'
Undefined

$ p6 'my Real $x; if $x.defined {say "Defined"}else{say "Undefined"};'
Undefined

$ p6 'my Real $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
Defined

$ p6 'my $x=3; if $x.defined {say "Defined"}else{say "Undefined"};'
Defined


$ p6 'my $x=3; dd $x'
Int $x = 3

$ p6 'my $x; dd $x'
Any $x = Any

$ p6 'my Real $x; dd $x'
Real $x = Real

$ p6 'my Real $x = 3; dd $x'
Int $x = 3

Huh ??


Re: escape codes

2018-09-16 Thread ToddAndMargo

On 09/16/2018 10:46 AM, yary wrote:

escape sequence


Hi All,

Once I knew what they were called, I found a list. It is for
Java, but I do believe most of its words in Parl6  And,
besides, the more grouchy members of comp.lang.perl.misc,
think Perl 6 is Java anyway.

Just added this:
RFE: May be have a section on Escape Characters?
https://github.com/perl6/doc/issues/2313

Thank you!
-T


https://en.wikipedia.org/wiki/Escape_character

\'  single quote
\" double quote
\\  backslash
\n  new line
\r  carriage return
\t  tab
\b  backspace
\f  form feed
\v  vertical tab (Internet Explorer 9 and older treats '\v
as 'v instead of a vertical tab ('\x0B). If cross-browser
compatibility is a concern, use \x0B instead of \v.)
\0  null character (U+ NULL) (only if the next character
is not a decimal digit; else it is an octal escape sequence)

Note that the \v and \0 escapes are not allowed in JSON strings.

$ p6 "say 'I am a single quote\'';"
I am a single quote'

$ p6 'say "I am a double quote\"";'
I am a double quote"

p6 'say "I am a backslash\\";'
I am a backslash\

$ p6 'say "";'


p6 'say "";'
>I am a carraige return

$ p6 'say "";'


$ p6 'say "";'


$ p6 'say "";'

$ p6 'say "";'
===SORRY!=== Error while compiling -e
Unrecognized backslash sequence: '\v'

$ p6 'say "";'



Re: escape codes

2018-09-16 Thread yary
One way to think about the word "escape" in "escape sequence" is about
escaping one string language for another. In the normal string language,
every character in is the same character out. Escape via \ and it's another
language where t is tab, r is carriage return, etc.

-y

On Sun, Sep 16, 2018 at 10:11 AM, The Sidhekin  wrote:

> On Sun, Sep 16, 2018 at 3:45 PM Parrot Raiser <1parr...@gmail.com> wrote:
>
>> -- Forwarded message --
>> From: Parrot Raiser <1parr...@gmail.com>
>> Date: Sun, 16 Sep 2018 09:41:44 -0400
>> Subject: Re: escape codes
>> To: ToddAndMargo 
>>
>> Those (\t & \n) aren't "escape characters", (though the \ is an
>> escape, so you might classify t & n a "escaped").
>>
>> I think the term you're looking for is "whitespace" characters.
>>
>
>   Or "escape sequences"?  See https://docs.perl6.org/
> language/syntax#Literals
>
>   (Yeah, the original escape sequences start with the Escape character,
> but that train has long left the station ...)
>
> Eirik
>


Re: Please explain this to me

2018-09-16 Thread yary
":D"
means it wants actual data in the string and not a Nil.
The jargon for this requirement is that is is constrained
to an actual value

If it wanted a Nil, it would say ":U" or constrained to
a Nil

Think of :D as a"defined" and :U as "Undefined" - Nil is a special thing,
even though Nil is undefined, it is one of many undefined things, and Nil
has some special uses. A better match for Perl5's "undef" is "Any".

In particular, this!

> my $example is default(5); say $example
5
> $example=Any; say $example
(Any)
> say $example.defined
False
> $example=Nil; say $example
5
> say $example.defined
True

-y


Re: escape codes

2018-09-16 Thread The Sidhekin
On Sun, Sep 16, 2018 at 3:45 PM Parrot Raiser <1parr...@gmail.com> wrote:

> -- Forwarded message --
> From: Parrot Raiser <1parr...@gmail.com>
> Date: Sun, 16 Sep 2018 09:41:44 -0400
> Subject: Re: escape codes
> To: ToddAndMargo 
>
> Those (\t & \n) aren't "escape characters", (though the \ is an
> escape, so you might classify t & n a "escaped").
>
> I think the term you're looking for is "whitespace" characters.
>

  Or "escape sequences"?  See
https://docs.perl6.org/language/syntax#Literals

  (Yeah, the original escape sequences start with the Escape character, but
that train has long left the station ...)

Eirik


Fwd: escape codes

2018-09-16 Thread Parrot Raiser
-- Forwarded message --
From: Parrot Raiser <1parr...@gmail.com>
Date: Sun, 16 Sep 2018 09:41:44 -0400
Subject: Re: escape codes
To: ToddAndMargo 

Those (\t & \n) aren't "escape characters", (though the \ is an
escape, so you might classify t & n a "escaped").

I think the term you're looking for is "whitespace" characters.
Although this https://perldoc.perl.org/perlglossary.html#whitespace is
from the Perl 5 docs, it should still work.


Re: Is this a bug?

2018-09-16 Thread Elizabeth Mattijsen
I don’t think we have a separate queue for REPL, so 
https://github.com/rakudo/rakudo/issues is the place

> On 16 Sep 2018, at 15:01, Fernando Santagata  
> wrote:
> 
> Should I report this here: https://github.com/rakudo/rakudo/ or there's a 
> specific location for the REPL?
> 
> On Sun, Sep 16, 2018 at 2:28 PM Elizabeth Mattijsen  wrote:
> Definitely a bug.  Which seems to be limited to the REPL only, fortunately.
> 
> > On 16 Sep 2018, at 12:57, Fernando Santagata  
> > wrote:
> > 
> > Hello,
> > 
> > I found this behavior quite strange:
> > 
> >> my int32 $a = 2
> > 2
> >> $a.^name
> > Int
> >> $a.WHAT
> > At Frame 1, Instruction 20, op 'getlex_ni', operand 0, MAST::Local of wrong 
> > type (3) specified; expected 4
> > 
> >> my num64 $b = 1.23e-2
> > 0.0123
> >> $b.^name
> > Num
> >> $b.WHAT
> > (Num)
> > 
> > This is Rakudo version 2018.08 built on MoarVM version 2018.08
> > 
> > -- 
> > Fernando Santagata
> 
> 
> -- 
> Fernando Santagata


Re: Is this a bug?

2018-09-16 Thread Fernando Santagata
Should I report this here: https://github.com/rakudo/rakudo/ or there's a
specific location for the REPL?

On Sun, Sep 16, 2018 at 2:28 PM Elizabeth Mattijsen  wrote:

> Definitely a bug.  Which seems to be limited to the REPL only, fortunately.
>
> > On 16 Sep 2018, at 12:57, Fernando Santagata 
> wrote:
> >
> > Hello,
> >
> > I found this behavior quite strange:
> >
> >> my int32 $a = 2
> > 2
> >> $a.^name
> > Int
> >> $a.WHAT
> > At Frame 1, Instruction 20, op 'getlex_ni', operand 0, MAST::Local of
> wrong type (3) specified; expected 4
> >
> >> my num64 $b = 1.23e-2
> > 0.0123
> >> $b.^name
> > Num
> >> $b.WHAT
> > (Num)
> >
> > This is Rakudo version 2018.08 built on MoarVM version 2018.08
> >
> > --
> > Fernando Santagata
>


-- 
Fernando Santagata


Re: Is this a bug?

2018-09-16 Thread Elizabeth Mattijsen
Definitely a bug.  Which seems to be limited to the REPL only, fortunately.

> On 16 Sep 2018, at 12:57, Fernando Santagata  
> wrote:
> 
> Hello,
> 
> I found this behavior quite strange:
> 
>> my int32 $a = 2
> 2
>> $a.^name
> Int
>> $a.WHAT
> At Frame 1, Instruction 20, op 'getlex_ni', operand 0, MAST::Local of wrong 
> type (3) specified; expected 4
> 
>> my num64 $b = 1.23e-2
> 0.0123
>> $b.^name
> Num
>> $b.WHAT
> (Num)
> 
> This is Rakudo version 2018.08 built on MoarVM version 2018.08
> 
> -- 
> Fernando Santagata


Information about Perl 6 internals

2018-09-16 Thread Fernando Santagata
Hello,

I'm developing an interface to libfftw3 (Fastest Fourier Transform in the
West).
The library provides a function to allocate SIMD-aligned memory (Single
Instruction Multiple Data), in order to maximize access speed to data.
Before I start to investigate a way to blandish a CArray into pointing to a
stretch of previously allocated memory, how does Perl 6 allocate memory?
Does it already use the SIMD alignment?

Since I'm here :-) will Perl 6 ever support a native type mirroring the
__float128 quadruple-precision type provided by gcc?

Thank you!

-- 
Fernando Santagata


Is this a bug?

2018-09-16 Thread Fernando Santagata
Hello,

I found this behavior quite strange:

> my int32 $a = 2
2
> $a.^name
Int
> $a.WHAT
At Frame 1, Instruction 20, op 'getlex_ni', operand 0, MAST::Local of wrong
type (3) specified; expected 4

> my num64 $b = 1.23e-2
0.0123
> $b.^name
Num
> $b.WHAT
(Num)

This is Rakudo version 2018.08 built on MoarVM version 2018.08

-- 
Fernando Santagata


escape codes

2018-09-16 Thread ToddAndMargo

Hi All,

Two question:

1) What is the official name for the escape codes
   used in strings?

print "Hi\tBye\n";

2) is there a list of them somewhere?

Many thanks,
-T


--
~
When we ask for advice, we are usually looking for an accomplice.
   --  Charles Varlet de La Grange
~


Re: .kv ?

2018-09-16 Thread ToddAndMargo

On 09/15/2018 03:16 PM, Brad Gilbert wrote:

Anyway I edited the Option Types post.


Hi Brad,

I like it!  That took some thinking.  You kicked it!

 To designate that it must have a defined value assigned to
 it (not be in the null state), use the :D "smiley" designation.

 It is also possible to designate that it must always be a
 null using the :U "smiley".

That `:U` thing comes in handy with NativeCall, where a totally
blank variable is required on the input.

-T


sub GetXDisplay () is export {
#`{
reference: man XDisplayName
char *XDisplayName(char *string);
sub display-name(Str:D $name) is native('X11') is 
symbol("XDisplayName") { * }


reference: 
https://tronche.com/gui/x/xlib/event-handling/protocol-errors/XDisplayName.html
The XDisplayName() function returns the name of the display 
that XOpenDisplay()
would attempt to use. If a NULL string is specified, 
XDisplayName() looks in the
environment for the display and returns the display name that 
XOpenDisplay() would
attempt to use. This makes it easier to report to the user 
precisely which display
the program attempted to open when the initial connection 
attempt failed.

}

   my $Display;
   my $NullStr; # Do not initialize this guy!

   # char *XDisplayName(char *string);
   sub XDisplayName(Str:D $name) is native('X11') returns Str { * };

   $Display = XDisplayName( $NullStr );
   return $Display;
}


Re: .kv ?

2018-09-16 Thread ToddAndMargo

On 09/15/2018 03:16 PM, Brad Gilbert wrote:

I'm just saying that brains are wired differently.


Hi Brad,

Oh no fooling.

I mainly make my living off of troubleshooting.  I
am I.T. for small businesses: Windows, Linux, and Mac.
(25 years at this now) When I arrive, I am frequently
not the first to have tried.  I always succeeded.  This
is because my brain is wired differently.  I see things
that others do not see. And sometimes don't see what
they see.  This is unusually not an issues, as the
"others" have already tried.

And I live for the easy ones.  But, that is usually not
my luck.  The worst one I had to unscramble had five
things affecting each other.  A affected B affected C
affected D Affected E affected A.  It took me two
hours to get it all wrapped around my head, but I
conquered where no one else could.  But had it
been a simple A affects B only, then ...

As my wife says about me "Some people only think inside
the box; some think outside the box; you have no box".
You have probably noticed this in my writing.  I freely
admit I am weird.

-T


Re: Need regex help

2018-09-16 Thread ToddAndMargo

On 09/15/2018 07:32 PM, Larry Wall wrote:

On Sat, Sep 15, 2018 at 06:45:33PM -0700, ToddAndMargo wrote:
: Hi All,
:
: I have been doing a bunch with regex's lately.
: I just throw them out based on prior experience
: and they most all work now.  I only sometimes have to
: ask for help.  (The look forward () feature
: is sweet.)
:
: Anyway, I have been using regex switches without
: knowing why. So
:
: What is the difference between
:
: \N

That is a character that is not any of the valid \n characters.

: :\N

That is not a thing.  That is a colon, which causes the previous thing
to not backtrack (if it would), followed by a \N (see above).

: <:\N>

That is not a thing.  In fact, it's a syntax error.

: <<\:N>>

That also is not a thing.  That is a left word boundary <<, followed by
\:, which matches a quote literally because it's backslashed, followed
by an N, which also matches literally, followed by the right word
boundary >>.  As a pattern, it is impossible for the combination to match,
since, while >> can match after a literal N, a << cannot match before a colon.

: And why would I choose one over the other (what
: are they called out for)?

I would never choose any of them, apart from \N.  Where are you getting
this craptastic list from?

Larry



Hi Larry,

Well.  I will have to go through my question with a fine
toothed comb and create a keeper tutorial for what I
come up with.  And in the process, I will no doubt trip
across a lot of stuff I got wrong.

It may be two weeks before I get back -- I have to finish
my company's federal taxes -- but I will get back with whagt I
come up with.

And to answer your question:  I got some of this stuff
from

https://docs.perl6.org/language/regexes#index-entry-regex_%3C%3Aproperty%3E-Unicode_properties

some from context (what I have seen), and

Well, the rest of it from, shall we say pulled out of
my ear.

Into everyone's life a little humiliation must fall.

Thank you for all your help with this.

-T