Re: tip: that annoying character at the end

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 10:11 PM ToddAndMargo  wrote:
>
> On 09/14/2018 07:34 PM, Brad Gilbert wrote:
> > $x ~~ s/ <:Cc>+ $ //;
>
> What exactly is <:Cc> again?

< and >  inside of a regular expression is for advanced features

If the first character is   :   then it knows to look for Unicode properties

One of those properties is GeneralCategory.

The General Category for the weird characters is Cc

( I think it is Control, common )

So this works

/ <:GeneralCategory> /

As a shortcut, you can leave off the "GeneralCategory" portion

/ <:Cc> /


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 08:09 PM, Brad Gilbert wrote:

I think that it is because of how you read.

The way your brain figures out what is written, is slow.


That is how the human the human brain works.  It is
always looking for patterns.  Depth perception for
instance.  Is that a shadow or an actual hole?
Sometimes it screws up royally.

"Look See" really did me a disservice.


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:52 PM, Curt Tilmes wrote:



On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo > wrote:


When I said "yet", I presumed the a variable can be
redefined at will:

$ p6 'my $x; say $x.perl;
           $x="abc"; say $x.perl;
           $x=Nil; say $x.perl;'
Any
"abc"
Any

And that the receiving method only cares what you feed it
at the time it is called.


Your example doesn't limit the type.  If you limit the type, you'll get 
an error

by assigning it something the type doesn't allow.

my Int $x;
$x = "abc"; # error can't put a string in an Int

my Int:U $x;
$x = 42; # error can't put a definite value in an Int:U

my Int:D $x = 42;
$x = Nil;   # error, can't undefine.

You're only allowed to put in things that fit.  If an argument to a 
routine is limited, you can only pass in things that fit.


Curt



Got it!  Thank you!

$ p6 'my Int:D $x = 42; $x = Nil;'
Type check failed in assignment to $x; expected type Int:D cannot be 
itself (perhaps Nil was assigned to a :D which had no default?)

  in block  at -e line 1

$ p6 'my Int:U $x = 42;'
Type check failed in assignment to $x; expected Int:U but got Int (42)
  in block  at -e line 1

-T



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


Re: Can methods have multiple inputs?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:48 PM, Brad Gilbert wrote:

On Fri, Sep 14, 2018 at 6:03 PM ToddAndMargo  wrote:



On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo mailto:toddandma...@zoho.com>> wrote:

 Hi All,

 Can a method be given multiple inputs?

   ( $a, $b ).foo

 and how would the docs write it?

   method foo(Any:D Any:D:  -->Bool)

 Is there a comma or a space between the two "any"'s?

 Many thanks,
 -T





On 09/14/2018 03:52 PM, Brandon Allbery wrote:

In that case, you're not giving it two items; you are giving it a single
List that happens to have two items within it. A method has one
invocant. If you are invoking method foo on that, its invocant is a List.

  > my $a; my $b; say ($a, $b).^name
List


Makes sense.  () turns it into a "List" so it
can be passed as one.

Thank you!


No () doesn't turn it into a list.

The comma turns it into a list

The () just act as a way to textually encapsulate the list

 (42).^name;  # Int
 (42, ).^name; # List

This is a very important distinction.

 [[[42]]].perl(); # [42]
 [[[42],],].perl(); # [[[42],],]

 (((42))).perl(); # 42
 (((42,),),).perl(); # (((42,),),)



Thank you!

--

Yesterday it worked.
Today it is not working.
Windows is like that.



Re: .kv ?

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 9:42 PM ToddAndMargo  wrote:
>
> On 09/14/2018 07:16 PM, Brad Gilbert wrote:
> > The author greatly appreciates the time spent on writing this critique.
> >
> > (I'm the author)
> >
> > Responses written inline
> >
> > On Fri, Sep 14, 2018 at 4:55 PM ToddAndMargo  wrote:
> >>
> >> On 09/14/2018 09:26 AM, Brad Gilbert wrote:
> >>> You can read https://en.wikipedia.org/wiki/Option_type for more 
> >>> information
> >>>
> >>> Tell me if you find any of the Perl 6 section confusing.
> >>> https://en.wikipedia.org/wiki/Option_type#Perl_6
> >>>
> >>
> >> Hi Brad,
> >>
> >> I had to read to top over very slowly.  Part of the issue was
> >> that I was not taught to read correctly.  (I was taught
> >> "Look See", instead of "Phonics").  I kept seeing other words,
> >> other than "nullable" and "non-nullable".  Eventually, I forced
> >> myself to use phonics and the words made sense.  This is not the
> >> authors problem, but mine alone.
> >
> > Yeah I remember thinking at the time that "non-nullable"
> > might be confusing.
> >
> > When I read, I "hear" the words. (usually in my voice)
> >
> > I will try to take into consideration to not use confusables
> > in the future.
> >
> >>"There are as many null values as there are types, that
> >>is because every type is its own null. So all types are
> >>also their own option type."
> >>
> >> Well stated.  Chuckle, in Modula2 a null is always 0H.
> >
> > If I remember correctly, the only reason I wrote it was
> > so that I could write down those two sentences.
> >
> > I think I even said them out loud to myself.
> >
> >>'To opt into a non-nullable version of a type add the :D
> >>"smiley" to it."
> >>
> >> This is confusing.  And I don't think correct, but I could be wrong.
> >
> > I stayed with the language that is on the rest of the page.
> >
> > It is correct, but it needs some further refinement/clarification.
> >
> > Really I should throw it out, and come up with a new sentence.
> >
> >> Curt stated it a lot better:
> >>
> >> If I say "my Int $x",
> >> $x is now an Int, but an undefined Int.
> >>
> >> If I say "my Int $x = 42",
> >> $x is an Int, but set to a defined value, 42.
> >>
> >> ":D" means that the variable is "defined".  "non-nullable" is
> >> a confusing way to state it.
> >
> > That is not *exactly* what :D means.
> > It means it can only ever be a defined value of that type or subtype.
> >
> > Curt was talking about something slightly different than what that
> > sentence talks about.
> >
> > Perhaps I could have written:
> >
> >  “To exclude null values, a :D "smiley" can be added.”
> >
> > I will think about this further when I am less tired.
> >
> >> It is also possible to opt into a type that is only
> >> ever a nullable using the :U "smiley".
> >>
> >> Curt's description is explains this perfectly. "is only
> >> ever a nullable" is confusing.  ":U" means that the
> >> variable has not got anything assigned to it yet.
> >
> > No, :U means it can **never** have anything other than a null assigned to 
> > it.
> >
> > Your statement was incorrect the moment you added "yet" instead of "ever".
> >
> > This is part of the reason I asked for your input.
> > I wanted to know exactly where your thoughts diverged, and
> > where I was less than clear.
> >
> > Now that I know both, I can hopefully make it so that people
> > who think and read like you do can understand it better.
> >
> >> To me ":D" means that the variable has something assigned to
> >> and ":U" means that the variable has yet to have anything
> >> assigned to it.
> >
> >  my Any:U $t;
> >  $t = Int;
> >  $t = Str;
> >  $t = 42;  # error
> >
> > Again "yet" is the wrong word.
> >
> >> If I were to rewrite this, I'd reverse D and U as that
> >> is the way they evolve.  All variables start out as :U.
> >>
> >>To designate a variable that does not have a value assigned
> >>to it yet and is still in the null state, use the :U designation.
> >>
> >>To designate a variable that must have a value assigned
> >>to it (not be in the null state), use the :D designation
> >
> > I described :D first as that is more useful than :U
> >
> > It is easier to describe.
> > It is also the default for the rest of the languages on the page.
> >
> > After describing :D, it then becomes easier to describe :U
> > as it is exactly opposite
> >
> > I may use your description of :D, at least as inspiration.
> >
> > I will look into this further when I am less tired.
> >
> >>
> >> The examples are excellent.
> >>
> >
> > Thank you.
> >
> > I remember worrying that it was so much longer than the rest of the
> > languages. (It's at least twice as long as the rest).
> >
> >> Coming from Modula2 and Pasca, one of the issues I had to content
> >> with when I picked started coding in Perl 5 was that in Modula2
> >> a variable is just a spot in memory with a 

Re: tip: that annoying character at the end

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:34 PM, Brad Gilbert wrote:

$x ~~ s/ <:Cc>+ $ //;


What exactly is <:Cc> again?


Re: Please explain this to me

2018-09-14 Thread ToddAndMargo

Okay,  see if I got it right, finally:


multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos --> Bool)

"multi method"
This means there are multiple ways to address this, as in

 multi method contains(Str:D: Cool:D $needle --> Bool)
 multi method contains(Str:D: Str:D $needle --> Bool)
 multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos 
--> Bool)

 multi method contains(Str:D: Str:D $needle, Int:D $pos --> Bool)

"Str"
means it want to be fed data as a string.  Str.foo

":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

":"
is the delimiter that tells you it is finished defining
what is wants to be fed

"Cool:D $needle"
means it wants a type Cool (string or number) for the
substring ($needle) it is looking for in the Haystack (Str)

"Int(Cool:D)"
Means it will change a type Cool into a type Int (integer)
and the ":D" means it want some actual data and not a Nil.

"$pos"
Is short of Position.  It is the starting index in the
haystack (Str) to start looking for the substring
(needle).  Index starts at zero by way of string
convention in Perl 6

$pos is an optional parameter.  Instead of $pos?
for optional, they stated it with several "multi method"
that do not include $pos.

"-->Bool"
means it return True or False


How did I do?

Thank you all for all the help with this!

-T


Re: .kv ?

2018-09-14 Thread Curt Tilmes
On Fri, Sep 14, 2018 at 10:52 PM Curt Tilmes  wrote:

>
>
> On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo 
> wrote:
>
>> When I said "yet", I presumed the a variable can be
>> redefined at will:
>>
>> $ p6 'my $x; say $x.perl;
>>   $x="abc"; say $x.perl;
>>   $x=Nil; say $x.perl;'
>> Any
>> "abc"
>> Any
>>
>> And that the receiving method only cares what you feed it
>> at the time it is called.
>>
>
> Your example doesn't limit the type.  If you limit the type, you'll get an
> error
> by assigning it something the type doesn't allow.
>
> my Int $x;
> $x = "abc"; # error can't put a string in an Int
>
> my Int:U $x;
> $x = 42; # error can't put a definite value in an Int:U
>
> my Int:D $x = 42;
> $x = Nil;   # error, can't undefine.
>
> You're only allowed to put in things that fit.  If an argument to a
> routine is limited, you can only pass in things that fit.
>

In other languages, we used to do things like:

int foo(char *str)
{
if (str == NULL) { ... do something like error out or whatever...}
... do the stuff we really came here for ...
}

Who wants to do their own error checking?  Perl 6 lets you shape your
'front door' so only the right stuff gets through:

multi method foo(Str:D $str)
{
   ... just get right to it -- I know I won't (can't!) get something not
defined ...
}

If you want to do your own error handling, just throw in another multi to
handle the undefined case:

multi method foo(Str:U $str)
{
   .. do something else -- this only gets called when $str isn't defined...
}

You can even throw in a 'broader' undefined type:

multi method foo(Any:U $str)

If I call foo() with an "Int:U" or "Rat:U", it will call that one.

Curt


Re: .kv ?

2018-09-14 Thread Curt Tilmes
On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo  wrote:

> When I said "yet", I presumed the a variable can be
> redefined at will:
>
> $ p6 'my $x; say $x.perl;
>   $x="abc"; say $x.perl;
>   $x=Nil; say $x.perl;'
> Any
> "abc"
> Any
>
> And that the receiving method only cares what you feed it
> at the time it is called.
>

Your example doesn't limit the type.  If you limit the type, you'll get an
error
by assigning it something the type doesn't allow.

my Int $x;
$x = "abc"; # error can't put a string in an Int

my Int:U $x;
$x = 42; # error can't put a definite value in an Int:U

my Int:D $x = 42;
$x = Nil;   # error, can't undefine.

You're only allowed to put in things that fit.  If an argument to a routine
is limited, you can only pass in things that fit.

Curt


Re: Can methods have multiple inputs?

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 6:03 PM ToddAndMargo  wrote:
>
> >> On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo  >> > wrote:
> >>
> >> Hi All,
> >>
> >> Can a method be given multiple inputs?
> >>
> >>   ( $a, $b ).foo
> >>
> >> and how would the docs write it?
> >>
> >>   method foo(Any:D Any:D:  -->Bool)
> >>
> >> Is there a comma or a space between the two "any"'s?
> >>
> >> Many thanks,
> >> -T
> >>
>
>
>
> On 09/14/2018 03:52 PM, Brandon Allbery wrote:
> > In that case, you're not giving it two items; you are giving it a single
> > List that happens to have two items within it. A method has one
> > invocant. If you are invoking method foo on that, its invocant is a List.
> >
> >  > my $a; my $b; say ($a, $b).^name
> > List
>
> Makes sense.  () turns it into a "List" so it
> can be passed as one.
>
> Thank you!

No () doesn't turn it into a list.

The comma turns it into a list

The () just act as a way to textually encapsulate the list

(42).^name;  # Int
(42, ).^name; # List

This is a very important distinction.

[[[42]]].perl(); # [42]
[[[42],],].perl(); # [[[42],],]

(((42))).perl(); # 42
(((42,),),).perl(); # (((42,),),)


Re: .kv ?

2018-09-14 Thread Brandon Allbery
But the point of this is the method is saying up front that it must be
given a variable that is defined; it's not waiting to test it or possibly
just bomb out later. This produces better error messages (the user doesn't
have to know about what's going on inside the method, the error cites the
method itself and not something buried in its guts) and in theory can make
things faster (this may not happen yet).

On Fri, Sep 14, 2018 at 10:42 PM ToddAndMargo  wrote:

> On 09/14/2018 07:16 PM, Brad Gilbert wrote:
> > The author greatly appreciates the time spent on writing this critique.
> >
> > (I'm the author)
> >
> > Responses written inline
> >
> > On Fri, Sep 14, 2018 at 4:55 PM ToddAndMargo 
> wrote:
> >>
> >> On 09/14/2018 09:26 AM, Brad Gilbert wrote:
> >>> You can read https://en.wikipedia.org/wiki/Option_type for more
> information
> >>>
> >>> Tell me if you find any of the Perl 6 section confusing.
> >>> https://en.wikipedia.org/wiki/Option_type#Perl_6
> >>>
> >>
> >> Hi Brad,
> >>
> >> I had to read to top over very slowly.  Part of the issue was
> >> that I was not taught to read correctly.  (I was taught
> >> "Look See", instead of "Phonics").  I kept seeing other words,
> >> other than "nullable" and "non-nullable".  Eventually, I forced
> >> myself to use phonics and the words made sense.  This is not the
> >> authors problem, but mine alone.
> >
> > Yeah I remember thinking at the time that "non-nullable"
> > might be confusing.
> >
> > When I read, I "hear" the words. (usually in my voice)
> >
> > I will try to take into consideration to not use confusables
> > in the future.
> >
> >>"There are as many null values as there are types, that
> >>is because every type is its own null. So all types are
> >>also their own option type."
> >>
> >> Well stated.  Chuckle, in Modula2 a null is always 0H.
> >
> > If I remember correctly, the only reason I wrote it was
> > so that I could write down those two sentences.
> >
> > I think I even said them out loud to myself.
> >
> >>'To opt into a non-nullable version of a type add the :D
> >>"smiley" to it."
> >>
> >> This is confusing.  And I don't think correct, but I could be wrong.
> >
> > I stayed with the language that is on the rest of the page.
> >
> > It is correct, but it needs some further refinement/clarification.
> >
> > Really I should throw it out, and come up with a new sentence.
> >
> >> Curt stated it a lot better:
> >>
> >> If I say "my Int $x",
> >> $x is now an Int, but an undefined Int.
> >>
> >> If I say "my Int $x = 42",
> >> $x is an Int, but set to a defined value, 42.
> >>
> >> ":D" means that the variable is "defined".  "non-nullable" is
> >> a confusing way to state it.
> >
> > That is not *exactly* what :D means.
> > It means it can only ever be a defined value of that type or subtype.
> >
> > Curt was talking about something slightly different than what that
> > sentence talks about.
> >
> > Perhaps I could have written:
> >
> >  “To exclude null values, a :D "smiley" can be added.”
> >
> > I will think about this further when I am less tired.
> >
> >> It is also possible to opt into a type that is only
> >> ever a nullable using the :U "smiley".
> >>
> >> Curt's description is explains this perfectly. "is only
> >> ever a nullable" is confusing.  ":U" means that the
> >> variable has not got anything assigned to it yet.
> >
> > No, :U means it can **never** have anything other than a null assigned
> to it.
> >
> > Your statement was incorrect the moment you added "yet" instead of
> "ever".
> >
> > This is part of the reason I asked for your input.
> > I wanted to know exactly where your thoughts diverged, and
> > where I was less than clear.
> >
> > Now that I know both, I can hopefully make it so that people
> > who think and read like you do can understand it better.
> >
> >> To me ":D" means that the variable has something assigned to
> >> and ":U" means that the variable has yet to have anything
> >> assigned to it.
> >
> >  my Any:U $t;
> >  $t = Int;
> >  $t = Str;
> >  $t = 42;  # error
> >
> > Again "yet" is the wrong word.
> >
> >> If I were to rewrite this, I'd reverse D and U as that
> >> is the way they evolve.  All variables start out as :U.
> >>
> >>To designate a variable that does not have a value assigned
> >>to it yet and is still in the null state, use the :U designation.
> >>
> >>To designate a variable that must have a value assigned
> >>to it (not be in the null state), use the :D designation
> >
> > I described :D first as that is more useful than :U
> >
> > It is easier to describe.
> > It is also the default for the rest of the languages on the page.
> >
> > After describing :D, it then becomes easier to describe :U
> > as it is exactly opposite
> >
> > I may use your description of :D, at least as inspiration.
> >
> > I will look into this further when I am 

Re: tip: that annoying character at the end

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:34 PM, Brad Gilbert wrote:

On Fri, Sep 14, 2018 at 7:49 PM ToddAndMargo  wrote:



On Fri, Sep 14, 2018 at 5:22 PM ToddAndMargo  wrote:


Hi All,

A tip to share.

I work a lot with downloaded web pages.  I cut
out things like revision numbers and download
locations.

One of the things that use to drive me a bit nuts was that
web pages can come with all kind of weird line terminators.
I'd wind up with a link location that bombed because
there was some weird unprintable character at the end.

Now there are routines to chop off these kind of things,
but they don't always work, depending on what the weird
character is.

What I had done in the past as to dump the page to a file
and use a hex editor to figure out what the weird character
was.  I have found ascii 0, 7, 10, 12, 13 and some other weird
ones I can't remember.  They often came is combinations too.
Then cut the turkey out with a regex.  It was a lot of work.

Now-a-days, it is easy.  I just get "greedy" (chuckle).
I always know what end of the string should be: .zip,
.exe, .rpm, etc..  So

  $Str ~~ s/ ".zip"  .* /.zip/;

  $ p6 'my $x="abc.zip"~chr(7)~chr(138); $x~~s/ ".zip" .* /.zip/; say
"<$x>";'
  

Problem solved.  And it doesn't care what the weird character(s)
at the end is/are.

:-)

Hope this helps someone else.  Thank you for all the
help you guys have given me!

-T



On 09/14/2018 05:43 PM, Brad Gilbert wrote:
  > You can just remove the control characters
  >
  > my $x="abc.zip"~chr(7)~chr(138);
  > $x .= subst(/<:Cc>+ $/,'');
  > say $x;
  >
  > Note that 13 is carriage return and 10 is newline
  >
  > If the only ending values are (13,10), 13, or 10
  > you can use .chomp to remove them
  >
  > my $x="abc.zip"~chr(13)~chr(10);
  > $x .= chomp;
  > say $x;

Thank you!

"chomp" was on of those routines I could only get
to work "sometimes".  It depended on what weird character(s)
I was dealing with.


`chomp` removes a trailing newline.



Would you explain what you are doing with
 $x .= subst(/<:Cc>+ $/,'');


Cc is the Unicode general category for control characters

 > say 7.uniprop;
 Cc

 > say 7.uniprop('General_Category')
 Cc

You can match things by category

Like numbers
 / <:N> /
decimal numbers
 / <:Nd> /
letter numbers
 / <:Nl> /
other numbers
 / <:No> /

letters
 / <:L> /
lowercase letters
 / <:Ll> /
uppercase letters
 / <:Lu> /
titlecase letters
 / <:Lt> /

It is exactly the same as

$x ~~ s/ <:Cc>+ $ //;

Originally I was just going to return the result of .subst()
rather than mutating $x.



Wow!  Thank you!

--
~~~
Serious error.
All shortcuts have disappeared.
Screen. Mind. Both are blank.
~~~


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 07:16 PM, Brad Gilbert wrote:

The author greatly appreciates the time spent on writing this critique.

(I'm the author)

Responses written inline

On Fri, Sep 14, 2018 at 4:55 PM ToddAndMargo  wrote:


On 09/14/2018 09:26 AM, Brad Gilbert wrote:

You can read https://en.wikipedia.org/wiki/Option_type for more information

Tell me if you find any of the Perl 6 section confusing.
https://en.wikipedia.org/wiki/Option_type#Perl_6



Hi Brad,

I had to read to top over very slowly.  Part of the issue was
that I was not taught to read correctly.  (I was taught
"Look See", instead of "Phonics").  I kept seeing other words,
other than "nullable" and "non-nullable".  Eventually, I forced
myself to use phonics and the words made sense.  This is not the
authors problem, but mine alone.


Yeah I remember thinking at the time that "non-nullable"
might be confusing.

When I read, I "hear" the words. (usually in my voice)

I will try to take into consideration to not use confusables
in the future.


   "There are as many null values as there are types, that
   is because every type is its own null. So all types are
   also their own option type."

Well stated.  Chuckle, in Modula2 a null is always 0H.


If I remember correctly, the only reason I wrote it was
so that I could write down those two sentences.

I think I even said them out loud to myself.


   'To opt into a non-nullable version of a type add the :D
   "smiley" to it."

This is confusing.  And I don't think correct, but I could be wrong.


I stayed with the language that is on the rest of the page.

It is correct, but it needs some further refinement/clarification.

Really I should throw it out, and come up with a new sentence.


Curt stated it a lot better:

If I say "my Int $x",
$x is now an Int, but an undefined Int.

If I say "my Int $x = 42",
$x is an Int, but set to a defined value, 42.

":D" means that the variable is "defined".  "non-nullable" is
a confusing way to state it.


That is not *exactly* what :D means.
It means it can only ever be a defined value of that type or subtype.

Curt was talking about something slightly different than what that
sentence talks about.

Perhaps I could have written:

 “To exclude null values, a :D "smiley" can be added.”

I will think about this further when I am less tired.


It is also possible to opt into a type that is only
ever a nullable using the :U "smiley".

Curt's description is explains this perfectly. "is only
ever a nullable" is confusing.  ":U" means that the
variable has not got anything assigned to it yet.


No, :U means it can **never** have anything other than a null assigned to it.

Your statement was incorrect the moment you added "yet" instead of "ever".

This is part of the reason I asked for your input.
I wanted to know exactly where your thoughts diverged, and
where I was less than clear.

Now that I know both, I can hopefully make it so that people
who think and read like you do can understand it better.


To me ":D" means that the variable has something assigned to
and ":U" means that the variable has yet to have anything
assigned to it.


 my Any:U $t;
 $t = Int;
 $t = Str;
 $t = 42;  # error

Again "yet" is the wrong word.


If I were to rewrite this, I'd reverse D and U as that
is the way they evolve.  All variables start out as :U.

   To designate a variable that does not have a value assigned
   to it yet and is still in the null state, use the :U designation.

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


I described :D first as that is more useful than :U

It is easier to describe.
It is also the default for the rest of the languages on the page.

After describing :D, it then becomes easier to describe :U
as it is exactly opposite

I may use your description of :D, at least as inspiration.

I will look into this further when I am less tired.



The examples are excellent.



Thank you.

I remember worrying that it was so much longer than the rest of the
languages. (It's at least twice as long as the rest).


Coming from Modula2 and Pasca, one of the issues I had to content
with when I picked started coding in Perl 5 was that in Modula2
a variable is just a spot in memory with a designated length.
A new variable contains whatever junk was in that memory location
when you started your program.  You very quickly learn to pre-salt
all your variables or you get caught in uninitialized variable hell.

In Perl, variables are structures.  There is a bunch of house keeping
involved.  The "my" declaration triggers this house keeping including
where it is and all the rules to access it.  The variable is pre-salted"
(null) very much so.  Perl is a ton easier to program in than Modula2.

Chuckle, the Perl 5 guy never did forgive me for calling Reference
Pointers "pointers".  I constantly had to 

Re: tip: that annoying character at the end

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 7:49 PM ToddAndMargo  wrote:
>
> > On Fri, Sep 14, 2018 at 5:22 PM ToddAndMargo  wrote:
> >>
> >> Hi All,
> >>
> >> A tip to share.
> >>
> >> I work a lot with downloaded web pages.  I cut
> >> out things like revision numbers and download
> >> locations.
> >>
> >> One of the things that use to drive me a bit nuts was that
> >> web pages can come with all kind of weird line terminators.
> >> I'd wind up with a link location that bombed because
> >> there was some weird unprintable character at the end.
> >>
> >> Now there are routines to chop off these kind of things,
> >> but they don't always work, depending on what the weird
> >> character is.
> >>
> >> What I had done in the past as to dump the page to a file
> >> and use a hex editor to figure out what the weird character
> >> was.  I have found ascii 0, 7, 10, 12, 13 and some other weird
> >> ones I can't remember.  They often came is combinations too.
> >> Then cut the turkey out with a regex.  It was a lot of work.
> >>
> >> Now-a-days, it is easy.  I just get "greedy" (chuckle).
> >> I always know what end of the string should be: .zip,
> >> .exe, .rpm, etc..  So
> >>
> >>  $Str ~~ s/ ".zip"  .* /.zip/;
> >>
> >>  $ p6 'my $x="abc.zip"~chr(7)~chr(138); $x~~s/ ".zip" .* /.zip/; say
> >> "<$x>";'
> >>  
> >>
> >> Problem solved.  And it doesn't care what the weird character(s)
> >> at the end is/are.
> >>
> >> :-)
> >>
> >> Hope this helps someone else.  Thank you for all the
> >> help you guys have given me!
> >>
> >> -T
>
>
> On 09/14/2018 05:43 PM, Brad Gilbert wrote:
>  > You can just remove the control characters
>  >
>  > my $x="abc.zip"~chr(7)~chr(138);
>  > $x .= subst(/<:Cc>+ $/,'');
>  > say $x;
>  >
>  > Note that 13 is carriage return and 10 is newline
>  >
>  > If the only ending values are (13,10), 13, or 10
>  > you can use .chomp to remove them
>  >
>  > my $x="abc.zip"~chr(13)~chr(10);
>  > $x .= chomp;
>  > say $x;
>
> Thank you!
>
> "chomp" was on of those routines I could only get
> to work "sometimes".  It depended on what weird character(s)
> I was dealing with.

`chomp` removes a trailing newline.

>
> Would you explain what you are doing with
> $x .= subst(/<:Cc>+ $/,'');

Cc is the Unicode general category for control characters

> say 7.uniprop;
Cc

> say 7.uniprop('General_Category')
Cc

You can match things by category

Like numbers
/ <:N> /
decimal numbers
/ <:Nd> /
letter numbers
/ <:Nl> /
other numbers
/ <:No> /

letters
/ <:L> /
lowercase letters
/ <:Ll> /
uppercase letters
/ <:Lu> /
titlecase letters
/ <:Lt> /

It is exactly the same as

   $x ~~ s/ <:Cc>+ $ //;

Originally I was just going to return the result of .subst()
rather than mutating $x.


Re: .kv ?

2018-09-14 Thread Brad Gilbert
The author greatly appreciates the time spent on writing this critique.

(I'm the author)

Responses written inline

On Fri, Sep 14, 2018 at 4:55 PM ToddAndMargo  wrote:
>
> On 09/14/2018 09:26 AM, Brad Gilbert wrote:
> > You can read https://en.wikipedia.org/wiki/Option_type for more information
> >
> > Tell me if you find any of the Perl 6 section confusing.
> > https://en.wikipedia.org/wiki/Option_type#Perl_6
> >
>
> Hi Brad,
>
> I had to read to top over very slowly.  Part of the issue was
> that I was not taught to read correctly.  (I was taught
> "Look See", instead of "Phonics").  I kept seeing other words,
> other than "nullable" and "non-nullable".  Eventually, I forced
> myself to use phonics and the words made sense.  This is not the
> authors problem, but mine alone.

Yeah I remember thinking at the time that "non-nullable"
might be confusing.

When I read, I "hear" the words. (usually in my voice)

I will try to take into consideration to not use confusables
in the future.

>   "There are as many null values as there are types, that
>   is because every type is its own null. So all types are
>   also their own option type."
>
> Well stated.  Chuckle, in Modula2 a null is always 0H.

If I remember correctly, the only reason I wrote it was
so that I could write down those two sentences.

I think I even said them out loud to myself.

>   'To opt into a non-nullable version of a type add the :D
>   "smiley" to it."
>
> This is confusing.  And I don't think correct, but I could be wrong.

I stayed with the language that is on the rest of the page.

It is correct, but it needs some further refinement/clarification.

Really I should throw it out, and come up with a new sentence.

> Curt stated it a lot better:
>
>If I say "my Int $x",
>$x is now an Int, but an undefined Int.
>
>If I say "my Int $x = 42",
>$x is an Int, but set to a defined value, 42.
>
> ":D" means that the variable is "defined".  "non-nullable" is
> a confusing way to state it.

That is not *exactly* what :D means.
It means it can only ever be a defined value of that type or subtype.

Curt was talking about something slightly different than what that
sentence talks about.

Perhaps I could have written:

“To exclude null values, a :D "smiley" can be added.”

I will think about this further when I am less tired.

>It is also possible to opt into a type that is only
>ever a nullable using the :U "smiley".
>
> Curt's description is explains this perfectly. "is only
> ever a nullable" is confusing.  ":U" means that the
> variable has not got anything assigned to it yet.

No, :U means it can **never** have anything other than a null assigned to it.

Your statement was incorrect the moment you added "yet" instead of "ever".

This is part of the reason I asked for your input.
I wanted to know exactly where your thoughts diverged, and
where I was less than clear.

Now that I know both, I can hopefully make it so that people
who think and read like you do can understand it better.

> To me ":D" means that the variable has something assigned to
> and ":U" means that the variable has yet to have anything
> assigned to it.

my Any:U $t;
$t = Int;
$t = Str;
$t = 42;  # error

Again "yet" is the wrong word.

> If I were to rewrite this, I'd reverse D and U as that
> is the way they evolve.  All variables start out as :U.
>
>   To designate a variable that does not have a value assigned
>   to it yet and is still in the null state, use the :U designation.
>
>   To designate a variable that must have a value assigned
>   to it (not be in the null state), use the :D designation

I described :D first as that is more useful than :U

It is easier to describe.
It is also the default for the rest of the languages on the page.

After describing :D, it then becomes easier to describe :U
as it is exactly opposite

I may use your description of :D, at least as inspiration.

I will look into this further when I am less tired.

>
> The examples are excellent.
>

Thank you.

I remember worrying that it was so much longer than the rest of the
languages. (It's at least twice as long as the rest).

> Coming from Modula2 and Pasca, one of the issues I had to content
> with when I picked started coding in Perl 5 was that in Modula2
> a variable is just a spot in memory with a designated length.
> A new variable contains whatever junk was in that memory location
> when you started your program.  You very quickly learn to pre-salt
> all your variables or you get caught in uninitialized variable hell.
>
> In Perl, variables are structures.  There is a bunch of house keeping
> involved.  The "my" declaration triggers this house keeping including
> where it is and all the rules to access it.  The variable is pre-salted"
> (null) very much so.  Perl is a ton easier to program in than Modula2.
>
> Chuckle, the Perl 5 guy never did forgive me for calling Reference
> 

Re: Please explain this to me

2018-09-14 Thread ToddAndMargo

On 09/11/2018 10:41 AM, Brandon Allbery wrote:
I'd like to point out that Todd is from Perl 5, which doesn't 
distinguish between subs and methods because its built-in OO is a 
minimalist hack. An introduction to true objects might be in order.


I never used a method in p5.  When I found them in
P6, I adored them.

Methods increase readability for me a lot.


Re: method vs multi method

2018-09-14 Thread ToddAndMargo

On 09/14/2018 04:33 PM, Ralph Mellor wrote:


      multi method kv ...

Use of `multi` means there *may* be more than one *declaration* using 
the same declared routine name (`kv` in this case). There usually *will* 
be more than one. (Otherwise, why was it declared `multi`?)


The normal way to *use* a routine is to call it.

If you declare multiple multis, then when you use (call) it, then the 
arguments you pass to it determine which one of of the multis gets chosen.


So 42.kv would pick the `Any:D` variant because `42` is a defined value.

Also, it there was only one way to use the method, would it be written:

      method kv(Any:  -->List)


It could be written any way you want.

But if you don't write `multi` then there's only one declaration.

And that means that when you call it, the arguments had better match 
that one declaration or you'll get an error.


Note that you can also be explicit that there's only one by using the 
declarator keyword `only`:


only method kv ...

--
raiph



Thank you!


Re: tip: that annoying character at the end

2018-09-14 Thread ToddAndMargo

On Fri, Sep 14, 2018 at 5:22 PM ToddAndMargo  wrote:


Hi All,

A tip to share.

I work a lot with downloaded web pages.  I cut
out things like revision numbers and download
locations.

One of the things that use to drive me a bit nuts was that
web pages can come with all kind of weird line terminators.
I'd wind up with a link location that bombed because
there was some weird unprintable character at the end.

Now there are routines to chop off these kind of things,
but they don't always work, depending on what the weird
character is.

What I had done in the past as to dump the page to a file
and use a hex editor to figure out what the weird character
was.  I have found ascii 0, 7, 10, 12, 13 and some other weird
ones I can't remember.  They often came is combinations too.
Then cut the turkey out with a regex.  It was a lot of work.

Now-a-days, it is easy.  I just get "greedy" (chuckle).
I always know what end of the string should be: .zip,
.exe, .rpm, etc..  So

 $Str ~~ s/ ".zip"  .* /.zip/;

 $ p6 'my $x="abc.zip"~chr(7)~chr(138); $x~~s/ ".zip" .* /.zip/; say
"<$x>";'
 

Problem solved.  And it doesn't care what the weird character(s)
at the end is/are.

:-)

Hope this helps someone else.  Thank you for all the
help you guys have given me!

-T



On 09/14/2018 05:43 PM, Brad Gilbert wrote:
> You can just remove the control characters
>
> my $x="abc.zip"~chr(7)~chr(138);
> $x .= subst(/<:Cc>+ $/,'');
> say $x;
>
> Note that 13 is carriage return and 10 is newline
>
> If the only ending values are (13,10), 13, or 10
> you can use .chomp to remove them
>
> my $x="abc.zip"~chr(13)~chr(10);
> $x .= chomp;
> say $x;

Thank you!

"chomp" was on of those routines I could only get
to work "sometimes".  It depended on what weird character(s)
I was dealing with.

Would you explain what you are doing with
   $x .= subst(/<:Cc>+ $/,'');


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 05:33 PM, Brad Gilbert wrote:

On Fri, Sep 14, 2018 at 7:10 PM ToddAndMargo  wrote:


On 09/14/2018 04:37 PM, Brandon Allbery wrote:


  "{$x}::{$y}"


Most of my programming before Perl 5 was bash.  I
did a lot of "${x}abc" to keep the variables
from being confused with each other.

I carried the practice over to perl 6 with
"{$x}abc" but the developers over on the chat
line told me not to do it.  I don't remember why,
(I just do everything they tell me.)

Now I just use an escape or a ~


There are some caveats using {} in a string literal

 > say "iteration: { ++$ }" xx 5
 (iteration: 1 iteration: 1 iteration: 1 iteration: 1 iteration: 1)
 > my $a; say "iteration: { ++$a }" xx 5
 (iteration: 1 iteration: 2 iteration: 3 iteration: 4 iteration: 5)

That is likely what they were talking about.

Basically these two bits of code are equivelent

 "{$x}::{$y}"

 "" ~ {$x}() ~ "::" ~ {$y}() ~ ""

So I wouldn't use {} if you can just use the variable itself.



Thank you!


Re: tip: that annoying character at the end

2018-09-14 Thread Brad Gilbert
You can just remove the control characters

   my $x="abc.zip"~chr(7)~chr(138);
   $x .= subst(/<:Cc>+ $/,'');
   say $x;

Note that 13 is carriage return and 10 is newline

If the only ending values are (13,10), 13, or 10
you can use .chomp to remove them

   my $x="abc.zip"~chr(13)~chr(10);
   $x .= chomp;
   say $x;
On Fri, Sep 14, 2018 at 5:22 PM ToddAndMargo  wrote:
>
> Hi All,
>
> A tip to share.
>
> I work a lot with downloaded web pages.  I cut
> out things like revision numbers and download
> locations.
>
> One of the things that use to drive me a bit nuts was that
> web pages can come with all kind of weird line terminators.
> I'd wind up with a link location that bombed because
> there was some weird unprintable character at the end.
>
> Now there are routines to chop off these kind of things,
> but they don't always work, depending on what the weird
> character is.
>
> What I had done in the past as to dump the page to a file
> and use a hex editor to figure out what the weird character
> was.  I have found ascii 0, 7, 10, 12, 13 and some other weird
> ones I can't remember.  They often came is combinations too.
> Then cut the turkey out with a regex.  It was a lot of work.
>
> Now-a-days, it is easy.  I just get "greedy" (chuckle).
> I always know what end of the string should be: .zip,
> .exe, .rpm, etc..  So
>
> $Str ~~ s/ ".zip"  .* /.zip/;
>
> $ p6 'my $x="abc.zip"~chr(7)~chr(138); $x~~s/ ".zip" .* /.zip/; say
> "<$x>";'
> 
>
> Problem solved.  And it doesn't care what the weird character(s)
> at the end is/are.
>
> :-)
>
> Hope this helps someone else.  Thank you for all the
> help you guys have given me!
>
> -T


Re: need p5/p6 :: help

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 7:10 PM ToddAndMargo  wrote:
>
> On 09/14/2018 04:37 PM, Brandon Allbery wrote:
>
> >  "{$x}::{$y}"
>
> Most of my programming before Perl 5 was bash.  I
> did a lot of "${x}abc" to keep the variables
> from being confused with each other.
>
> I carried the practice over to perl 6 with
> "{$x}abc" but the developers over on the chat
> line told me not to do it.  I don't remember why,
> (I just do everything they tell me.)
>
> Now I just use an escape or a ~

There are some caveats using {} in a string literal

> say "iteration: { ++$ }" xx 5
(iteration: 1 iteration: 1 iteration: 1 iteration: 1 iteration: 1)
> my $a; say "iteration: { ++$a }" xx 5
(iteration: 1 iteration: 2 iteration: 3 iteration: 4 iteration: 5)

That is likely what they were talking about.

Basically these two bits of code are equivelent

"{$x}::{$y}"

"" ~ {$x}() ~ "::" ~ {$y}() ~ ""

So I wouldn't use {} if you can just use the variable itself.


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 04:37 PM, Brandon Allbery wrote:


 "{$x}::{$y}"


Most of my programming before Perl 5 was bash.  I
did a lot of "${x}abc" to keep the variables
from being confused with each other.

I carried the practice over to perl 6 with
"{$x}abc" but the developers over on the chat
line told me not to do it.  I don't remember why,
(I just do everything they tell me.)

Now I just use an escape or a ~


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 7:32 PM ToddAndMargo > wrote:


What is this all about?


$ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
===SORRY!=== Error while compiling -e
Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
at -e:1
--> my $x="abc"; my $y="def"; say "$x⏏::$y";

$ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
abc::def

$ p6 'say "abc::def";'
abc::def

What does the compiler think `::$y` is?

Many thanks,
-T


On 09/14/2018 04:37 PM, Brandon Allbery wrote:
It thinks it's interpolating a variable $x::... and then it gets stuck 
because it sees $y instead of the rest of a variable name. You can use 
braces to control what's part of the name:


pyanfar Z$ 6 'my $x = "abc"; my $y = "def"; say "{$x}::{$y}"'
abc::def

Otherwise, you couldn't interpolate the name of a variable $x::y in some 
other module.




Makes sense, I think.  I have just been using an escape
   $a\::$b


Re: need p5/p6 :: help

2018-09-14 Thread Brandon Allbery
It thinks it's interpolating a variable $x::... and then it gets stuck
because it sees $y instead of the rest of a variable name. You can use
braces to control what's part of the name:

pyanfar Z$ 6 'my $x = "abc"; my $y = "def"; say "{$x}::{$y}"'
abc::def

Otherwise, you couldn't interpolate the name of a variable $x::y in some
other module.


On Fri, Sep 14, 2018 at 7:32 PM ToddAndMargo  wrote:

> What is this all about?
>
>
> $ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
> ===SORRY!=== Error while compiling -e
> Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
> at -e:1
> --> my $x="abc"; my $y="def"; say "$x⏏::$y";
>
> $ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
> abc::def
>
> $ p6 'say "abc::def";'
> abc::def
>
> What does the compiler think `::$y` is?
>
> Many thanks,
> -T
>


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


Re: .new?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 03:39 AM, Timo Paulssen wrote:

Telemetry::Sampler isn't a routine, it's a class. You can follow the
link labelled "from Telemetry::Sampler" to get to the documentation of
the class by that name, which explains what it is, how you get it, and
how you use it.

I'll file a bug for the "new" routine page.

Hope that helps!
   - Timo


Thank you!


Re: method vs multi method

2018-09-14 Thread Ralph Mellor
>  multi method kv ...


Use of `multi` means there *may* be more than one *declaration* using the
same declared routine name (`kv` in this case). There usually *will* be
more than one. (Otherwise, why was it declared `multi`?)

The normal way to *use* a routine is to call it.

If you declare multiple multis, then when you use (call) it, then the
arguments you pass to it determine which one of of the multis gets chosen.

So 42.kv would pick the `Any:D` variant because `42` is a defined value.

Also, it there was only one way to use the method, would it be written:
>
>  method kv(Any:  -->List)
>

It could be written any way you want.

But if you don't write `multi` then there's only one declaration.

And that means that when you call it, the arguments had better match that
one declaration or you'll get an error.

Note that you can also be explicit that there's only one by using the
declarator keyword `only`:

only method kv ...

--
raiph


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

What is this all about?


$ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
===SORRY!=== Error while compiling -e
Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
at -e:1
--> my $x="abc"; my $y="def"; say "$x⏏::$y";

$ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
abc::def

$ p6 'say "abc::def";'
abc::def

What does the compiler think `::$y` is?

Many thanks,
-T


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 12:49 PM, Larry Wall wrote:

On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote:
: Also, did you answer my question about "::" and did it
: just go over my head?

The implication was that "::" didn't change, but the default package
scoping of p5 that you're relying on is no longer the default in p6.

: The p5 guys use to tell me "its lexiconical", meaning it was figured
: out on the fly.  (Took me forever to catch on.)  Is that any
: relation to your use of the word "lexical"?

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".

: https://www.dictionary.com/browse/lexical?s=t
:
:adjective
:
:of or relating to the words or vocabulary of a language,
:especially as distinguished from its grammatical and
:syntactical aspects.
:
:of, relating to, or of the nature of a lexicon.

The relationship of lexicons to lexical scoping here is a bit tenuous,
but it goes something like this: Every scope in your program can define
things local to that scope.  When a scope does define something, it's
creating a new lexicon of terms, like a private lingo or patois for a
given workplace that no other workplace will understand.  It is that
set of private definitions (overlaid on all the definitions pulled in
from larger scopes) that functions as a "dictionary" here.

So when people say "lexically scoped", they mean there are multiple lexicons,
and each symbol is looked in the nearest one that actually has a definition
for the term.  The whole point of "scoping" is to decide what is near, and
what is far.

So, for instance, you may have worked in a workplace or participated
in a forum where the local lexicon of the "p5 guys" contained the
word "lexiconical" with some kind of idiosyncratic meaning involving
dynamic lookup.  That term is not used in the larger p5 culture that
way, so people outside that workplace or forum will not understand that
idiosyncratic definition of "lexiconical", which seems to have nothing
whatsoever to do with lexicons.

Lexical scoping is not figured out on the fly; it's figured out while the
code is compiling.  You can have delayed compilation when you eval a string,
of course, but then the fact that the lexical lookups are delayed is not
a special feature of the lexicon; everything related to the compiler is
delayed when you eval.  "Figured out on the fly" is a feature of eval, not
of lexicons.

Now, all that being said, in p5 subroutines are looked up in packages,
and packages are modifiable, so we do have to discover what to call "on
the fly" in that case.  But in p5 culture we never refer to packages as
lexicons because that would confuse people.

In Perl 6 culture we never mix them up either, but we also never put subs
into packages by default.  The reason Foo::bar notation doesn't work is
because bar isn't in Foo anymore unless you explicitly put it there.

Larry



Thank you!


Re: Can methods have multiple inputs?

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo > wrote:


Hi All,

Can a method be given multiple inputs?

  ( $a, $b ).foo

and how would the docs write it?

  method foo(Any:D Any:D:  -->Bool)

Is there a comma or a space between the two "any"'s?

Many thanks,
-T





On 09/14/2018 03:52 PM, Brandon Allbery wrote:
In that case, you're not giving it two items; you are giving it a single 
List that happens to have two items within it. A method has one 
invocant. If you are invoking method foo on that, its invocant is a List.


 > my $a; my $b; say ($a, $b).^name
List


Makes sense.  () turns it into a "List" so it
can be passed as one.

Thank you!


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 12:49 PM, Larry Wall wrote:

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".


Hi Larry,

I did a google and duckduckgo search through
comp.lang.perl.misc for lexiconical and came up
short, except for something I wrote on the "C"
list.

At the time, those guys had my head spinning.  I
come from Modula2 and the concept of type Any
did not resonate.  They were trying to explain
how a variable could be different types, depending
on what you assigned to it.

-T


Re: Can methods have multiple inputs?

2018-09-14 Thread Brandon Allbery
In that case, you're not giving it two items; you are giving it a single
List that happens to have two items within it. A method has one invocant.
If you are invoking method foo on that, its invocant is a List.

> my $a; my $b; say ($a, $b).^name
List


On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo  wrote:

> Hi All,
>
> Can a method be given multiple inputs?
>
>  ( $a, $b ).foo
>
> and how would the docs write it?
>
>  method foo(Any:D Any:D:  -->Bool)
>
> Is there a comma or a space between the two "any"'s?
>
> Many thanks,
> -T
>


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


Re: .kv ?

2018-09-14 Thread Brandon Allbery
They do different things if it's defined vs. if it's undefined. This is
preferred to having an if-then test in a single implementation, if they're
different enough that you're really writing two functions anyway.

And List is supposed to be vague there. At the level of Any, it can be a
list of anything. To be more specific about the result, you need an
implementation on specific types instead of on Any; but most of those
implementations would be doing exactly the same thing, only the signature
being different. Which is silly and wasteful and makes the computer dig
though a sea of identical functions for no reason.

On Fri, Sep 14, 2018 at 6:41 PM ToddAndMargo  wrote:

> On 09/14/2018 03:10 PM, Brandon Allbery wrote:
> > On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo  > > wrote:
> >
> >'To opt into a non-nullable version of a type add the :D
> >"smiley" to it."
> >
> > This is confusing.  And I don't think correct, but I could be wrong.
> > Curt stated it a lot better:
> >
> > If I say "my Int $x",
> > $x is now an Int, but an undefined Int.
> >
> > If I say "my Int $x = 42",
> > $x is an Int, but set to a defined value, 42.
> >
> > ":D" means that the variable is "defined".  "non-nullable" is
> > a confusing way to state it.
> >
> >
> > Not exactly. "Defined" is a "now" thing; "non-nullable", via type
> > smileys, is an "always" thing. It is defined now, and it can never be
> > undefined.
> >
> > To me ":D" means that the variable has something assigned to
> > and ":U" means that the variable has yet to have anything
> > assigned to it.
> >
> > If I were to rewrite this, I'd reverse D and U as that
> > is the way they evolve.  All variables start out as :U.
> >
> >
> > This is the same misunderstanding: what is now, is not guaranteed to be
> > so in the future. :U and :D provide such guarantees. Merely being
> > defined or undefined right now says nothing about the future.
>
>
> Hi Brandon,
>
> Thank you!
>
> My use for the "smileys" is in methods definitions.  It tells me
> that the variable has to have a value or a null.
>
> For instance:
>  multi method kv(Any:U:  -->List)
>  multi method kv(Any:D:  -->List)
>
> is their way of saying I can use either.
>
> Question,  why don't they just say?
>  method kv(Any:  -->List)
>
> And "List" is really vague, as in what kind of list?
>
> -T
>


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


Can methods have multiple inputs?

2018-09-14 Thread ToddAndMargo

Hi All,

Can a method be given multiple inputs?

( $a, $b ).foo

and how would the docs write it?

method foo(Any:D Any:D:  -->Bool)

Is there a comma or a space between the two "any"'s?

Many thanks,
-T


method vs multi method

2018-09-14 Thread ToddAndMargo

Hi All,

In the following:
https://docs.perl6.org/routine/kv

multi method kv(Any:U:  -->List)
multi method kv(Any:D:  -->List)

Does the "multi" mean ther are moe than one way to
use the method, as in see the two instances above?
Or something else?

Also, it there was only one way to use the method,
would it be written:

method kv(Any:  -->List)


Many thanks,
-T


Re: need p5/p6 :: help

2018-09-14 Thread Elizabeth Mattijsen
> On 15 Sep 2018, at 00:12, Vadim Belman  wrote:
>> In Perl 6 culture we never mix them up either, but we also never put subs
>> into packages by default.  The reason Foo::bar notation doesn't work is
>> because bar isn't in Foo anymore unless you explicitly put it there.
> Though technically this aspect was clear to me, but to settle things down in 
> my mind completely: for now ordinary (not 'our') sub belongs not to the 
> package object but to the block which belongs to that package. Is it correct 
> way to describe things?

Yes.

And you can even introspect it:

{
sub foo() { }
# check out this scope’s lexpad for subroutines
.say for MY::.keys.grep: *.starts-with('&’);   # 
}
# check out outer scope’s lexpad for subroutines
say for MY::.keys.grep: *.starts-with('&’);  # nothing

Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 03:10 PM, Brandon Allbery wrote:
On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo > wrote:


       'To opt into a non-nullable version of a type add the :D
       "smiley" to it."

This is confusing.  And I don't think correct, but I could be wrong.
Curt stated it a lot better:

        If I say "my Int $x",
        $x is now an Int, but an undefined Int.

        If I say "my Int $x = 42",
        $x is an Int, but set to a defined value, 42.

":D" means that the variable is "defined".  "non-nullable" is
a confusing way to state it.


Not exactly. "Defined" is a "now" thing; "non-nullable", via type 
smileys, is an "always" thing. It is defined now, and it can never be 
undefined.


To me ":D" means that the variable has something assigned to
and ":U" means that the variable has yet to have anything
assigned to it.

If I were to rewrite this, I'd reverse D and U as that
is the way they evolve.  All variables start out as :U.


This is the same misunderstanding: what is now, is not guaranteed to be 
so in the future. :U and :D provide such guarantees. Merely being 
defined or undefined right now says nothing about the future.



Hi Brandon,

Thank you!

My use for the "smileys" is in methods definitions.  It tells me
that the variable has to have a value or a null.

For instance:
multi method kv(Any:U:  -->List)
multi method kv(Any:D:  -->List)

is their way of saying I can use either.

Question,  why don't they just say?
method kv(Any:  -->List)

And "List" is really vague, as in what kind of list?

-T


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 03:03 PM, ToddAndMargo wrote:

On 09/14/2018 02:55 PM, ToddAndMargo wrote:

In Perl, variables are structures.  There is a bunch of house keeping
involved.  The "my" declaration triggers this house keeping including
where it is and all the rules to access it.  The variable is pre-salted"
(null) very much so.  Perl is a ton easier to program in than Modula2.


Oh one of the things I had to stop doing was wondering
what was going on in the background.

For instance "my" initialized the structure and pre-salts
the guy getting it ready for you to use.  It is indeed
"initialized" but in the background or you couldn't use it.

In the foreground, best not to think about the background
and just see it as ready to go and in an initialized state.
The is the beauty of a high level language.


That should have been an "initialized state" at the end.


tip: that annoying character at the end

2018-09-14 Thread ToddAndMargo

Hi All,

A tip to share.

I work a lot with downloaded web pages.  I cut
out things like revision numbers and download
locations.

One of the things that use to drive me a bit nuts was that
web pages can come with all kind of weird line terminators.
I'd wind up with a link location that bombed because
there was some weird unprintable character at the end.

Now there are routines to chop off these kind of things,
but they don't always work, depending on what the weird
character is.

What I had done in the past as to dump the page to a file
and use a hex editor to figure out what the weird character
was.  I have found ascii 0, 7, 10, 12, 13 and some other weird
ones I can't remember.  They often came is combinations too.
Then cut the turkey out with a regex.  It was a lot of work.

Now-a-days, it is easy.  I just get "greedy" (chuckle).
I always know what end of the string should be: .zip,
.exe, .rpm, etc..  So

   $Str ~~ s/ ".zip"  .* /.zip/;

   $ p6 'my $x="abc.zip"~chr(7)~chr(138); $x~~s/ ".zip" .* /.zip/; say 
"<$x>";'

   

Problem solved.  And it doesn't care what the weird character(s)
at the end is/are.

:-)

Hope this helps someone else.  Thank you for all the
help you guys have given me!

-T


Re: need p5/p6 :: help

2018-09-14 Thread Vadim Belman
> 
> In Perl 6 culture we never mix them up either, but we also never put subs
> into packages by default.  The reason Foo::bar notation doesn't work is
> because bar isn't in Foo anymore unless you explicitly put it there.
> 
> Larry
> 


Though technically this aspect was clear to me, but to settle things down in my 
mind completely: for now ordinary (not 'our') sub belongs not to the package 
object but to the block which belongs to that package. Is it correct way to 
describe things?

Best regards,
Vadim Belman


Re: .kv ?

2018-09-14 Thread Brandon Allbery
On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo  wrote:

>   'To opt into a non-nullable version of a type add the :D
>   "smiley" to it."
>
> This is confusing.  And I don't think correct, but I could be wrong.
> Curt stated it a lot better:
>
>If I say "my Int $x",
>$x is now an Int, but an undefined Int.
>
>If I say "my Int $x = 42",
>$x is an Int, but set to a defined value, 42.
>
> ":D" means that the variable is "defined".  "non-nullable" is
> a confusing way to state it.
>

Not exactly. "Defined" is a "now" thing; "non-nullable", via type smileys,
is an "always" thing. It is defined now, and it can never be undefined.


> To me ":D" means that the variable has something assigned to
> and ":U" means that the variable has yet to have anything
> assigned to it.
>
> If I were to rewrite this, I'd reverse D and U as that
> is the way they evolve.  All variables start out as :U.
>

This is the same misunderstanding: what is now, is not guaranteed to be so
in the future. :U and :D provide such guarantees. Merely being defined or
undefined right now says nothing about the future.

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


Re: ->

2018-09-14 Thread Parrot Raiser
On 9/14/18, Brandon Allbery  wrote:
> And then you discover <->.
>

Elbows?


Re: ->

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 5:10 PM Parrot Raiser <1parr...@gmail.com 
> wrote:


Obviously, discussions about "->" will be easier if it has a name. How
about "lance", or, if you want to be less martial, "poker'?


On 09/14/2018 02:11 PM, Brandon Allbery wrote:

And then you discover <->.



One of the fun things about Perl is the sense of humor: pointy,
slurp, spurt, greedy, and many more I am sure I have still to find.

This actually help me remember things.  I always chuckle a bit
when I write `.*`


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 02:55 PM, ToddAndMargo wrote:

In Perl, variables are structures.  There is a bunch of house keeping
involved.  The "my" declaration triggers this house keeping including
where it is and all the rules to access it.  The variable is pre-salted"
(null) very much so.  Perl is a ton easier to program in than Modula2.


Oh one of the things I had to stop doing was wondering
what was going on in the background.

For instance "my" initialized the structure and pre-salts
the guy getting it ready for you to use.  It is indeed
"initialized" but in the background or you couldn't use it.

In the foreground, best not to think about the background
and just see it as ready to go and in an initialized state.
The is the beauty of a high level language.


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 04:31 AM, Simon Proctor wrote:

Just look at Curt's explanation.


I found it last night.  I rather admire his
technical writing ability.  He made the complex
look simple.  And that is a talent.


Re: .kv ?

2018-09-14 Thread ToddAndMargo

On 09/14/2018 09:26 AM, Brad Gilbert wrote:

You can read https://en.wikipedia.org/wiki/Option_type for more information

Tell me if you find any of the Perl 6 section confusing.
https://en.wikipedia.org/wiki/Option_type#Perl_6



Hi Brad,

I had to read to top over very slowly.  Part of the issue was
that I was not taught to read correctly.  (I was taught
"Look See", instead of "Phonics").  I kept seeing other words,
other than "nullable" and "non-nullable".  Eventually, I forced
myself to use phonics and the words made sense.  This is not the
authors problem, but mine alone.

 "There are as many null values as there are types, that
 is because every type is its own null. So all types are
 also their own option type."

Well stated.  Chuckle, in Modula2 a null is always 0H.

 'To opt into a non-nullable version of a type add the :D
 "smiley" to it."

This is confusing.  And I don't think correct, but I could be wrong.
Curt stated it a lot better:

  If I say "my Int $x",
  $x is now an Int, but an undefined Int.

  If I say "my Int $x = 42",
  $x is an Int, but set to a defined value, 42.

":D" means that the variable is "defined".  "non-nullable" is
a confusing way to state it.


  It is also possible to opt into a type that is only
  ever a nullable using the :U "smiley".

Curt's description is explains this perfectly. "is only
ever a nullable" is confusing.  ":U" means that the
variable has not got anything assigned to it yet.

To me ":D" means that the variable has something assigned to
and ":U" means that the variable has yet to have anything
assigned to it.

If I were to rewrite this, I'd reverse D and U as that
is the way they evolve.  All variables start out as :U.

 To designate a variable that does not have a value assigned
 to it yet and is still in the null state, use the :U designation.

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

The examples are excellent.

Coming from Modula2 and Pasca, one of the issues I had to content
with when I picked started coding in Perl 5 was that in Modula2
a variable is just a spot in memory with a designated length.
A new variable contains whatever junk was in that memory location
when you started your program.  You very quickly learn to pre-salt
all your variables or you get caught in uninitialized variable hell.

In Perl, variables are structures.  There is a bunch of house keeping
involved.  The "my" declaration triggers this house keeping including
where it is and all the rules to access it.  The variable is pre-salted"
(null) very much so.  Perl is a ton easier to program in than Modula2.

Chuckle, the Perl 5 guy never did forgive me for calling Reference
Pointers "pointers".  I constantly had to remind them
that there were different kinds of pointers than those found
in "C", which only points to a spot in memory.  Perl's pointers
point to the variables structure or "reference" and all the
associated rules.

HTH,
-T

They also got huffy with me calling hashes "associative arrays",
which they are.  When I quoted them Larry's reasoning on the
subject (hash is easier to write), they shut up.  But I
could tell it still rankled.

I don't know why they were so huffy.  "Associative Array"
help me wrap my mind around what exactly my favorite variable
was.


Re: ->

2018-09-14 Thread Brandon Allbery
And then you discover <->.

On Fri, Sep 14, 2018 at 5:10 PM Parrot Raiser <1parr...@gmail.com> wrote:

> Obviously, discussions about "->" will be easier if it has a name. How
> about "lance", or, if you want to be less martial, "poker'?
>


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


Re: ->

2018-09-14 Thread Parrot Raiser
Obviously, discussions about "->" will be easier if it has a name. How
about "lance", or, if you want to be less martial, "poker'?


Re: ->

2018-09-14 Thread Brandon Allbery
Pick a glyph, any glyph….

On Fri, Sep 14, 2018 at 4:54 PM ToddAndMargo  wrote:

> On 09/14/2018 01:09 PM, Mike Stok wrote:
> >
> >
> >> On Sep 14, 2018, at 4:03 PM, ToddAndMargo 
> wrote:
> >>
> >> On 09/14/2018 01:00 PM, Larry Wall wrote:
> >>>
> >>>  "-> is how we spell λ in Perl 6"
> >>> Larry
> >>
> >>
> >> Hysterical!  Thank you!
> >
> > I would like to think
> https://kwangyulseo.com/2015/06/23/the-origin-of-notation-λ-in-lambda-calculus/
> is the truth.
>
> “Why in the world, did you choose lambda as your operator?”
> Church’s response: “eeny meeny miny moe”.
>
> :-D
>


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


Re: ->

2018-09-14 Thread ToddAndMargo

On 09/14/2018 01:09 PM, Mike Stok wrote:




On Sep 14, 2018, at 4:03 PM, ToddAndMargo  wrote:

On 09/14/2018 01:00 PM, Larry Wall wrote:


 "-> is how we spell λ in Perl 6"
Larry



Hysterical!  Thank you!


I would like to think 
https://kwangyulseo.com/2015/06/23/the-origin-of-notation-λ-in-lambda-calculus/ 
is the truth.


“Why in the world, did you choose lambda as your operator?”
Church’s response: “eeny meeny miny moe”.

:-D


Re: ->

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 4:16 PM ToddAndMargo > wrote:


On 09/14/2018 12:27 PM, ToddAndMargo wrote:
 > Hi All,
 >
 > I use `->` all the time.  What is its official name?
 >
 > for @x.kv -> $I, $Line {...}
 >
 > Many thanks,
 > -T

Me thinks I am pushing "pointy" here!

#!/usr/bin/env perl6
sub Stooges() { return ( "Larry", "Curley", "Moe" ); }
my $x; my $y; my $z;

# ($x, $y, $z ) = Stooges;
Stooges -> $x, $y, $z;
say "$x  $y  $z";


$ Lambda.Test.pl6
===SORRY!=== Error while compiling /home/linuxutil/./Lambda.Test.pl6
Invalid typename 'say' in parameter declaration.
at /home/linuxutil/./Lambda.Test.pl6:10
--> say⏏ "$x  $y  $z";


Am I missing something here, or did I just get a little
too creative for my own good?

Many thanks,
-T


On 09/14/2018 01:23 PM, Brandon Allbery wrote:
It's still reading the block signature (parameters and return type) that 
it expects after the ->, until it sees the start of the block/closure.


Think of what follows it as a sub declaration without the sub name or 
parentheses. A semicolon there says that what follows are optional 
parameters, so it's expecting either a parameter name, or a type to give 
to the following parameter name.


So it needs a {} to work with.  Rats!

Thank you!


Re: ->

2018-09-14 Thread Brandon Allbery
It's still reading the block signature (parameters and return type) that it
expects after the ->, until it sees the start of the block/closure.

Think of what follows it as a sub declaration without the sub name or
parentheses. A semicolon there says that what follows are optional
parameters, so it's expecting either a parameter name, or a type to give to
the following parameter name.

On Fri, Sep 14, 2018 at 4:16 PM ToddAndMargo  wrote:

> On 09/14/2018 12:27 PM, ToddAndMargo wrote:
> > Hi All,
> >
> > I use `->` all the time.  What is its official name?
> >
> > for @x.kv -> $I, $Line {...}
> >
> > Many thanks,
> > -T
>
> Me thinks I am pushing "pointy" here!
>
> #!/usr/bin/env perl6
> sub Stooges() { return ( "Larry", "Curley", "Moe" ); }
> my $x; my $y; my $z;
>
> # ($x, $y, $z ) = Stooges;
> Stooges -> $x, $y, $z;
> say "$x  $y  $z";
>
>
> $ Lambda.Test.pl6
> ===SORRY!=== Error while compiling /home/linuxutil/./Lambda.Test.pl6
> Invalid typename 'say' in parameter declaration.
> at /home/linuxutil/./Lambda.Test.pl6:10
> --> say⏏ "$x  $y  $z";
>
>
> Am I missing something here, or did I just get a little
> too creative for my own good?
>
> Many thanks,
> -T
>


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


Re: ->

2018-09-14 Thread ToddAndMargo

On 09/14/2018 12:27 PM, ToddAndMargo wrote:

Hi All,

I use `->` all the time.  What is its official name?

for @x.kv -> $I, $Line {...}

Many thanks,
-T


Me thinks I am pushing "pointy" here!

#!/usr/bin/env perl6
sub Stooges() { return ( "Larry", "Curley", "Moe" ); }
my $x; my $y; my $z;

# ($x, $y, $z ) = Stooges;
Stooges -> $x, $y, $z;
say "$x  $y  $z";


$ Lambda.Test.pl6
===SORRY!=== Error while compiling /home/linuxutil/./Lambda.Test.pl6
Invalid typename 'say' in parameter declaration.
at /home/linuxutil/./Lambda.Test.pl6:10
--> say⏏ "$x  $y  $z";


Am I missing something here, or did I just get a little
too creative for my own good?

Many thanks,
-T


Re: ->

2018-09-14 Thread Mike Stok



> On Sep 14, 2018, at 4:03 PM, ToddAndMargo  wrote:
> 
> On 09/14/2018 01:00 PM, Larry Wall wrote:
>> 
>> "-> is how we spell λ in Perl 6"
>> Larry
> 
> 
> Hysterical!  Thank you!

I would like to think 
https://kwangyulseo.com/2015/06/23/the-origin-of-notation-λ-in-lambda-calculus/ 
is the truth.

Thanks to unicode I think I can type x̂.2x + 1 these days and avoid those 
“pretentious” greek letters ;-)

Mike

-- 

Mike Stok 
http://www.stok.ca/~mike/

The "`Stok' disclaimers" apply.


Re: ->

2018-09-14 Thread ToddAndMargo

On 09/14/2018 01:00 PM, Larry Wall wrote:

On Fri, Sep 14, 2018 at 09:30:51PM +0200, Elizabeth Mattijsen wrote:
: The combination of “->” and “{ }” is sometimes referred to as a “pointy 
block”, or even maybe just a “pointy”.

Note that "pointy" is specifically referring to the syntax here, not the
semantics.  People use other terms when they want to talk about semantics.

Sometimes when people are talking about functional programming, they'll
call this a "lambda" because that's what anonymous functions are
often called in FP.  Because Lisp, originally

That's a completely arbitrary name that is relatively non-descriptive.
(Which could be said for most of the uses of greek letters in academia...)

So for something more descriptive, lambdas will often be called
"closures" when you're referring to the way they capture ("close over",
to a mathematician) a snapshot of external variables.

Though "lambda" also implies this to someone who speaks the Functional
Programming lingo.  So if you meet an FP person and want to sound smart,
just tell them:

 "-> is how we spell λ in Perl 6"

Larry




Hysterical!  Thank you!


Re: ->

2018-09-14 Thread Larry Wall
On Fri, Sep 14, 2018 at 09:30:51PM +0200, Elizabeth Mattijsen wrote:
: The combination of “->” and “{ }” is sometimes referred to as a “pointy 
block”, or even maybe just a “pointy”.

Note that "pointy" is specifically referring to the syntax here, not the
semantics.  People use other terms when they want to talk about semantics.

Sometimes when people are talking about functional programming, they'll
call this a "lambda" because that's what anonymous functions are
often called in FP.  Because Lisp, originally

That's a completely arbitrary name that is relatively non-descriptive.
(Which could be said for most of the uses of greek letters in academia...)

So for something more descriptive, lambdas will often be called
"closures" when you're referring to the way they capture ("close over",
to a mathematician) a snapshot of external variables.

Though "lambda" also implies this to someone who speaks the Functional
Programming lingo.  So if you meet an FP person and want to sound smart,
just tell them:

"-> is how we spell λ in Perl 6"

Larry


Re: need p5/p6 :: help

2018-09-14 Thread Larry Wall
On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote:
: Also, did you answer my question about "::" and did it
: just go over my head?

The implication was that "::" didn't change, but the default package
scoping of p5 that you're relying on is no longer the default in p6.

: The p5 guys use to tell me "its lexiconical", meaning it was figured
: out on the fly.  (Took me forever to catch on.)  Is that any
: relation to your use of the word "lexical"?

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".

: https://www.dictionary.com/browse/lexical?s=t
: 
:adjective
: 
:of or relating to the words or vocabulary of a language,
:especially as distinguished from its grammatical and
:syntactical aspects.
: 
:of, relating to, or of the nature of a lexicon.

The relationship of lexicons to lexical scoping here is a bit tenuous,
but it goes something like this: Every scope in your program can define
things local to that scope.  When a scope does define something, it's
creating a new lexicon of terms, like a private lingo or patois for a
given workplace that no other workplace will understand.  It is that
set of private definitions (overlaid on all the definitions pulled in
from larger scopes) that functions as a "dictionary" here.

So when people say "lexically scoped", they mean there are multiple lexicons,
and each symbol is looked in the nearest one that actually has a definition
for the term.  The whole point of "scoping" is to decide what is near, and
what is far.

So, for instance, you may have worked in a workplace or participated
in a forum where the local lexicon of the "p5 guys" contained the
word "lexiconical" with some kind of idiosyncratic meaning involving
dynamic lookup.  That term is not used in the larger p5 culture that
way, so people outside that workplace or forum will not understand that
idiosyncratic definition of "lexiconical", which seems to have nothing
whatsoever to do with lexicons.

Lexical scoping is not figured out on the fly; it's figured out while the
code is compiling.  You can have delayed compilation when you eval a string,
of course, but then the fact that the lexical lookups are delayed is not
a special feature of the lexicon; everything related to the compiler is
delayed when you eval.  "Figured out on the fly" is a feature of eval, not
of lexicons.

Now, all that being said, in p5 subroutines are looked up in packages,
and packages are modifiable, so we do have to discover what to call "on
the fly" in that case.  But in p5 culture we never refer to packages as
lexicons because that would confuse people.

In Perl 6 culture we never mix them up either, but we also never put subs
into packages by default.  The reason Foo::bar notation doesn't work is
because bar isn't in Foo anymore unless you explicitly put it there.

Larry


Re: ->

2018-09-14 Thread Brandon Allbery
It's part of a "pointy block". But this doesn't seem to be documented
directly as such, it's only mentioned at
https://docs.perl6.org/language/control#for .

On Fri, Sep 14, 2018 at 3:28 PM ToddAndMargo  wrote:

> Hi All,
>
> I use `->` all the time.  What is its official name?
>
> for @x.kv -> $I, $Line {...}
>
> Many thanks,
> -T
>


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


Re: ->

2018-09-14 Thread Elizabeth Mattijsen
The combination of “->” and “{ }” is sometimes referred to as a “pointy block”, 
or even maybe just a “pointy”.  The thing(s) inbetween the “->” and “{ }” are 
the “signature” of the “pointy block”.

> On 14 Sep 2018, at 21:27, ToddAndMargo  wrote:
> 
> Hi All,
> 
> I use `->` all the time.  What is its official name?
> 
> for @x.kv -> $I, $Line {...}
> 
> Many thanks,
> -T


->

2018-09-14 Thread ToddAndMargo

Hi All,

I use `->` all the time.  What is its official name?

for @x.kv -> $I, $Line {...}

Many thanks,
-T


Re: need p5/p6 :: help

2018-09-14 Thread Brad Gilbert
lexical means it is only available within that scope,
or in sub-scopes

{
my $a;
{
$a = 42;
}
}
$a  # error

{
sub foo (){}
# my sub foo (){}  # identical
{
foo();
}
}
foo() # error

---

Note that

sub foo (){}

is really short for

my only sub foo (){}

The `only` and the `my` are implied

---

For something to be attached to a namespace
it has to be declared as `our` or `has`.

module Foo {
constant Bar = 42;
# our constant Bar = 42; # identical

our sub foo (){64} # in the namespace
}
say Foo::Bar; # 42
say Baz::foo; # 64

class Baz {
method bar (){42}
# has method bar (){42} # identical

our sub foo (){64}
}
say Baz.bar; # 42
say Baz::foo; # 64
On Fri, Sep 14, 2018 at 6:15 AM Todd Chester  wrote:
>
>  > On 14/09/2018 12:59, Todd Chester wrote:
>  >> Hi All,
>  >>
>  >> I am in the process of converting a YUGE program I wrote in
>  >> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
>  >> so I could tell where something came from.
>  >>
>  >> I take it "::" means something different is Perl 6 than Perl 5.
>  >>
>  >> $ p6 'use lib "/home/linuxutil"; use PrintColors;
>  >> PrintColors::PrintRed "Hi\n";'
>  >>
>  >> Could not find symbol ''
>  >>in block  at -e line 1
>  >>
>  >> In p5 "PrintColors::PrintRed" means to use the routine called
>  >> "PrintRed" found in a modules called "PrintColors".
>  >>
>  >> Does p6 have an equivalent?
>  >>
>  >> Many thanks,
>  >> -T
>
> On 09/14/2018 04:01 AM, Timo Paulssen wrote:
> > It's important for the PrintRed sub inside PrintColors to be declared
> > "our", otherwise it is "my" scoped, i.e. limited to the lexical extent
> > of the module file.
> >
>
> sub PrintRed   ( $Str ) is export { print color('bold'), color('red'),
> "$Str", color('reset'); }
>
> I have never understood the use of "our" in a module.
> I can't tell the difference.
>
> Also, did you answer my question about "::" and did it
> just go over my head?
>
> The p5 guys use to tell me "its lexiconical", meaning it was figured
> out on the fly.  (Took me forever to catch on.)  Is that any
> relation to your use of the word "lexical"?
>
> https://www.dictionary.com/browse/lexical?s=t
>
> adjective
>
> of or relating to the words or vocabulary of a language,
> especially as distinguished from its grammatical and
> syntactical aspects.
>
> of, relating to, or of the nature of a lexicon.
>
> -T


Re: .kv ?

2018-09-14 Thread Brad Gilbert
You can read https://en.wikipedia.org/wiki/Option_type for more information

Tell me if you find any of the Perl 6 section confusing.
https://en.wikipedia.org/wiki/Option_type#Perl_6

On Fri, Sep 14, 2018 at 6:21 AM Todd Chester  wrote:
>
> >> On Fri, Sep 14, 2018 at 7:08 AM Todd Chester  >> > wrote:
> >>
> >>
> >>
> >> On 09/14/2018 04:01 AM, Simon Proctor wrote:
> >>  > :D is a type constraint requiring an instantiated (or defined)
> >> object of
> >>  > the given type (or a subtype of it).
> >>  >
> >>  > :U is a type constraint saying you have a container specified for
> >> the
> >>  > given type that hasn't been instantiated.
> >>
> >> Hi Simon,
> >>
> >> Your went over my head.  What the heck is "instantiated"?
> >>
> >> https://www.dictionary.com/browse/instantiate
> >> verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.
> >>
> >>   to provide an instance of or concrete evidence in support
> >>   of (a theory, concept, claim, or the like).
> >>
> >> I am not connecting the dots.
> >>
> >> Is there a list of these guys somewhere, or are these the only two?
> >>
> >> -T
> >>
>
>
>
> On 09/14/2018 04:16 AM, Curt Tilmes wrote:
> > See
> > https://docs.perl6.org/type/Signature#Constraining_defined_and_undefined_values
> >
> > If I say "my Int $x",
> > $x is now an Int, but an undefined Int.
> >
> > If I say "my Int $x = 42",
> > $x is an Int, but set to a defined value, 42.
> >
> > Both are Int:
> >
> > say 42 ~~ Int; # OUTPUT: «True␤»
> > say Int ~~ Int; # OUTPUT: «True␤»
> >
> >
> > There are three type constraint suffixes you can add -- :D (defined), :U
> > (undefined) or :_ (defined or undefined)
> >
> > # Checking a type object
> > say Int ~~ Any:D; # OUTPUT: «False␤»
> > say Int ~~ Any:U; # OUTPUT: «True␤»
> > say Int ~~ Any:_; # OUTPUT: «True␤»
> > # Checking an object instance
> > say 42 ~~ Any:D; # OUTPUT: «True␤»
> > say 42 ~~ Any:U; # OUTPUT: «False␤»
> > say 42 ~~ Any:_; # OUTPUT: «True␤»
> >
> >
> >
>
> Hi Curt,
>
> Beautiful explanation!  I am writing it down tomorrow
> in my keepers file.
>
> Thank you!
>
> -T


Re: .new?

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 6:19 AM Todd Chester  wrote:
>
>
>
> On 09/14/2018 03:34 AM, Simon Proctor wrote:
> > I think the docs of objects (sorry on my phone no link) describe object
> > creation and the default new quite well.
>
> They most probably are and most developers would have no issues
> figuring them out.
>
> If a common user can't make heads or tails out of them, then
> they need some work.  Perl 5's perldocs are wonderfully easy
> to understand.  The developers have their own specifications.
> The Docs need to be understandable by the riff raff.
>
>  > Do a search for objects.
>
> What do you mean?
>
> Can you throw an example at me?

In the Perl 6 docs you often are looking for a subroutine or a method
indiscriminately. So the routine pages pull from both lists dynamically.

That is what happened here.

In the case of `.new()` this is a really bad idea.
That is because every object has a new.

Since the pages for routines pull the method documentation out of its
broader context, it can sometimes be confusing.
The broader context being the pages for the types themselves.

This works decently for things like `.substr()` because there is really
only one type which that works on, and is fairly easy to guess about
the wider context.

In the case of `.new()` there is no way to guess about the wider
context.
It is also one of the methods that most people would just get,
so the documentation for each instance of this method
only describes the differences from the norm.

Basically the documentation for `.new()` needs to be hand-crafted.


Re: .new?

2018-09-14 Thread Parrot Raiser
> Do a search for objects.

What do you mean?

Into you favourite search engine, e.g. duckduckgo, type perl6 objects


Re: .kv ?

2018-09-14 Thread Simon Proctor
Just look at Curt's explanation.

On Fri, 14 Sep 2018, 12:22 Todd Chester,  wrote:

>
>
> On 09/14/2018 04:18 AM, Simon Proctor wrote:
> > Assigned, created or defined.
> >
> > Basically the object has a value.
>
> Not following.  Are there three of them?
>


Re: .kv ?

2018-09-14 Thread Todd Chester




On 09/14/2018 04:18 AM, Simon Proctor wrote:

Assigned, created or defined.

Basically the object has a value.


Not following.  Are there three of them?


Re: .kv ?

2018-09-14 Thread Todd Chester
On Fri, Sep 14, 2018 at 7:08 AM Todd Chester > wrote:




On 09/14/2018 04:01 AM, Simon Proctor wrote:
 > :D is a type constraint requiring an instantiated (or defined)
object of
 > the given type (or a subtype of it).
 >
 > :U is a type constraint saying you have a container specified for
the
 > given type that hasn't been instantiated.

Hi Simon,

Your went over my head.  What the heck is "instantiated"?

https://www.dictionary.com/browse/instantiate
verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.

  to provide an instance of or concrete evidence in support
  of (a theory, concept, claim, or the like).

I am not connecting the dots.

Is there a list of these guys somewhere, or are these the only two?

-T





On 09/14/2018 04:16 AM, Curt Tilmes wrote:
See 
https://docs.perl6.org/type/Signature#Constraining_defined_and_undefined_values


If I say "my Int $x",
$x is now an Int, but an undefined Int.

If I say "my Int $x = 42",
$x is an Int, but set to a defined value, 42.

Both are Int:

say 42 ~~ Int; # OUTPUT: «True␤»
say Int ~~ Int; # OUTPUT: «True␤»


There are three type constraint suffixes you can add -- :D (defined), :U 
(undefined) or :_ (defined or undefined)


# Checking a type object
say Int ~~ Any:D; # OUTPUT: «False␤»
say Int ~~ Any:U; # OUTPUT: «True␤»
say Int ~~ Any:_; # OUTPUT: «True␤»
# Checking an object instance
say 42 ~~ Any:D; # OUTPUT: «True␤»
say 42 ~~ Any:U; # OUTPUT: «False␤»
say 42 ~~ Any:_; # OUTPUT: «True␤»





Hi Curt,

Beautiful explanation!  I am writing it down tomorrow
in my keepers file.

Thank you!

-T


Re: .new?

2018-09-14 Thread Todd Chester




On 09/14/2018 03:34 AM, Simon Proctor wrote:
I think the docs of objects (sorry on my phone no link) describe object 
creation and the default new quite well.


They most probably are and most developers would have no issues
figuring them out.

If a common user can't make heads or tails out of them, then
they need some work.  Perl 5's perldocs are wonderfully easy
to understand.  The developers have their own specifications.
The Docs need to be understandable by the riff raff.

> Do a search for objects.

What do you mean?

Can you throw an example at me?


Re: .kv ?

2018-09-14 Thread Simon Proctor
Assigned, created or defined.

Basically the object has a value.

On Fri, 14 Sep 2018, 12:08 Todd Chester,  wrote:

>
>
> On 09/14/2018 04:01 AM, Simon Proctor wrote:
> > :D is a type constraint requiring an instantiated (or defined) object of
> > the given type (or a subtype of it).
> >
> > :U is a type constraint saying you have a container specified for the
> > given type that hasn't been instantiated.
>
> Hi Simon,
>
> Your went over my head.  What the heck is "instantiated"?
>
> https://www.dictionary.com/browse/instantiate
> verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.
>
>  to provide an instance of or concrete evidence in support
>  of (a theory, concept, claim, or the like).
>
> I am not connecting the dots.
>
> Is there a list of these guys somewhere, or are these the only two?
>
> -T
>


Re: .kv ?

2018-09-14 Thread Curt Tilmes
See
https://docs.perl6.org/type/Signature#Constraining_defined_and_undefined_values

If I say "my Int $x",
$x is now an Int, but an undefined Int.

If I say "my Int $x = 42",
$x is an Int, but set to a defined value, 42.

Both are Int:

say  42 ~~ Int;   # OUTPUT: «True␤»
say Int ~~ Int;   # OUTPUT: «True␤»


There are three type constraint suffixes you can add -- :D (defined), :U
(undefined) or :_ (defined or undefined)

# Checking a type object
say Int ~~ Any:D;# OUTPUT: «False␤»
say Int ~~ Any:U;# OUTPUT: «True␤»
say Int ~~ Any:_;# OUTPUT: «True␤»

# Checking an object instance
say 42 ~~ Any:D; # OUTPUT: «True␤»
say 42 ~~ Any:U; # OUTPUT: «False␤»
say 42 ~~ Any:_; # OUTPUT: «True␤»



On Fri, Sep 14, 2018 at 7:08 AM Todd Chester  wrote:

>
>
> On 09/14/2018 04:01 AM, Simon Proctor wrote:
> > :D is a type constraint requiring an instantiated (or defined) object of
> > the given type (or a subtype of it).
> >
> > :U is a type constraint saying you have a container specified for the
> > given type that hasn't been instantiated.
>
> Hi Simon,
>
> Your went over my head.  What the heck is "instantiated"?
>
> https://www.dictionary.com/browse/instantiate
> verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.
>
>  to provide an instance of or concrete evidence in support
>  of (a theory, concept, claim, or the like).
>
> I am not connecting the dots.
>
> Is there a list of these guys somewhere, or are these the only two?
>
> -T
>


Re: need p5/p6 :: help

2018-09-14 Thread Todd Chester

> On 14/09/2018 12:59, Todd Chester wrote:
>> Hi All,
>>
>> I am in the process of converting a YUGE program I wrote in
>> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
>> so I could tell where something came from.
>>
>> I take it "::" means something different is Perl 6 than Perl 5.
>>
>> $ p6 'use lib "/home/linuxutil"; use PrintColors;
>> PrintColors::PrintRed "Hi\n";'
>>
>> Could not find symbol ''
>>in block  at -e line 1
>>
>> In p5 "PrintColors::PrintRed" means to use the routine called
>> "PrintRed" found in a modules called "PrintColors".
>>
>> Does p6 have an equivalent?
>>
>> Many thanks,
>> -T

On 09/14/2018 04:01 AM, Timo Paulssen wrote:

It's important for the PrintRed sub inside PrintColors to be declared
"our", otherwise it is "my" scoped, i.e. limited to the lexical extent
of the module file.



sub PrintRed   ( $Str ) is export { print color('bold'), color('red'), 
"$Str", color('reset'); }


I have never understood the use of "our" in a module.
I can't tell the difference.

Also, did you answer my question about "::" and did it
just go over my head?

The p5 guys use to tell me "its lexiconical", meaning it was figured
out on the fly.  (Took me forever to catch on.)  Is that any
relation to your use of the word "lexical"?

https://www.dictionary.com/browse/lexical?s=t

   adjective

   of or relating to the words or vocabulary of a language,
   especially as distinguished from its grammatical and
   syntactical aspects.

   of, relating to, or of the nature of a lexicon.

-T


Re: .kv ?

2018-09-14 Thread Todd Chester




On 09/14/2018 04:01 AM, Simon Proctor wrote:
:D is a type constraint requiring an instantiated (or defined) object of 
the given type (or a subtype of it).


:U is a type constraint saying you have a container specified for the 
given type that hasn't been instantiated.


Hi Simon,

Your went over my head.  What the heck is "instantiated"?

https://www.dictionary.com/browse/instantiate
verb (used with object), in·stan·ti·at·ed, in·stan·ti·at·ing.

to provide an instance of or concrete evidence in support
of (a theory, concept, claim, or the like).

I am not connecting the dots.

Is there a list of these guys somewhere, or are these the only two?

-T


Re: I need -M help

2018-09-14 Thread Todd Chester

> On 14/09/2018 12:52, Todd Chester wrote:
>> Hi All,
>>
>> With a one liner, how to I load a module that resides in the
>> current directory?

On 09/14/2018 03:58 AM, Timo Paulssen wrote:

The equivalent of "use lib 'blah'" on the commandline is "-I blah", just
like "-M bloop" is the equivalent of "use 'bloop'" in code.

HTH
   - Timo



Hi Timo,

Perfect!  Thank you!

$ perl6 -I./ -M./PrintColors -e 'PrintRed "Hi\n";'
Hi

-T


Re: need p5/p6 :: help

2018-09-14 Thread Timo Paulssen
It's important for the PrintRed sub inside PrintColors to be declared
"our", otherwise it is "my" scoped, i.e. limited to the lexical extent
of the module file.

On 14/09/2018 12:59, Todd Chester wrote:
> Hi All,
>
> I am in the process of converting a YUGE program I wrote in
> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
> so I could tell where something came from.
>
> I take it "::" means something different is Perl 6 than Perl 5.
>
> $ p6 'use lib "/home/linuxutil"; use PrintColors;
> PrintColors::PrintRed "Hi\n";'
>
> Could not find symbol ''
>   in block  at -e line 1
>
> In p5 "PrintColors::PrintRed" means to use the routine called
> "PrintRed" found in a modules called "PrintColors".
>
> Does p6 have an equivalent?
>
> Many thanks,
> -T


Re: .kv ?

2018-09-14 Thread Simon Proctor
:D is a type constraint requiring an instantiated (or defined) object of
the given type (or a subtype of it).

:U is a type constraint saying you have a container specified for the given
type that hasn't been instantiated.

So if you have my Int $a; you have said this should hold and Int but it's
currently valueless (undefined). It would match Int:U in a signature.

Assign 5 to it and it's now defined and matches Int:D in a signature.

On Fri, 14 Sep 2018, 11:44 Todd Chester,  wrote:

> >> On Fri, 14 Sep 2018, 11:22 Todd Chester,  >> > wrote:
> >>
> >> Hi All,
> >>
> >> I adore the "kv" method:
> >>
> >> $ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i  $j" };'
> >> 0  abc
> >> 1  23
> >> 2  4.56
> >>
> >> So, I decided to go and look at:
> >> https://docs.perl6.org/routine/kv
> >>
> >> multi method kv(Any:U:  -->List)
> >> multi method kv(Any:D:  -->List)
> >>
> >>
> >> Okay, here is what I see:
> >>
> >> "method"  is .foo style of a routine
> >>
> >> "Any:U:" and "Any:D:" are what goes in front of .foo
> >> and it can be of type "Any".
> >>
> >> https://docs.perl6.org/type/Any
> >>
> >>":D" mean constrained, meaning it much have something
> >>
> >>What is ":U"?
> >>
> >>Whatever ":U", how can it be both?
> >>
> >> The second ":" is the delimiter for what goes in front of the .foo,
> >> meaning it has finished its declaration of what that in front is.
> >> Kind of like a comma.
> >>
> >> "-->List" mean something is returned of type "List"
> >> https://docs.perl6.org/type/List
> >>
> >>0  abc
> >>1  23
> >>2  4.56
> >>
> >>
> >> How have I done so far?
> >>
> >>
> >> And is there a list somewhere of the meanings of ":U" and ":D"
> >> and such so the next time I see one that I do not recognize,
> >> I can look it up?
> >>
> >> Many thanks,
> >> -T
> >>
>
>
> On 09/14/2018 03:28 AM, Simon Proctor wrote:
> > :D means a defined value. So it's when you have an instance. :U is
> > undefined so it's when you call kv as a classethod.
> >
> > Pair.kv would be :U.
> > (A => "b").kv would be :D
> >
> >
>
> Hi Simion,
>
> I am not following.  What do you mean by "undefined"?
>
> I can't make head or tails out of "Pair"
> https://docs.perl6.org/type/Pair
>
> I thought ":D" meant "constrained"?
>
> Yours in confusion ,
> -T
>


Re: .new?

2018-09-14 Thread Todd Chester




On 09/14/2018 03:37 AM, Elizabeth Mattijsen wrote:

Good catch!


I am not sure exactly what I tripped across, but as
I tell my wife "sometimes it pays to be an idiot."

:-)

-T


need p5/p6 :: help

2018-09-14 Thread Todd Chester

Hi All,

I am in the process of converting a YUGE program I wrote in
Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
so I could tell where something came from.

I take it "::" means something different is Perl 6 than Perl 5.

$ p6 'use lib "/home/linuxutil"; use PrintColors; PrintColors::PrintRed 
"Hi\n";'


Could not find symbol ''
  in block  at -e line 1

In p5 "PrintColors::PrintRed" means to use the routine called
"PrintRed" found in a modules called "PrintColors".

Does p6 have an equivalent?

Many thanks,
-T


Re: I need -M help

2018-09-14 Thread Timo Paulssen
The equivalent of "use lib 'blah'" on the commandline is "-I blah", just
like "-M bloop" is the equivalent of "use 'bloop'" in code.

HTH
  - Timo

On 14/09/2018 12:52, Todd Chester wrote:
> Hi All,
>
> With a one liner, how to I load a module that resides in the
> current directory?
>
> $ ls PrintColors.pm6
> PrintColors.pm6
>
>
> $ perl6 -MPrintColors -e 'PrintRed "Hi";'
> ===SORRY!===
> Could not find PrintColors at line 1 in:
>     /home/tony/.perl6
>     /opt/rakudo-pkg/share/perl6/site
>     /opt/rakudo-pkg/share/perl6/vendor
>     /opt/rakudo-pkg/share/perl6
>     CompUnit::Repository::AbsolutePath<58670368>
>     CompUnit::Repository::NQP<53138976>
>     CompUnit::Repository::Perl5<53139016>
>
>
> $ perl6 -M./PrintColors -e 'PrintRed "Hi";'
> ===SORRY!===
> Could not find ./PrintColors at line 1 in:
>     /home/tony/.perl6
>     /opt/rakudo-pkg/share/perl6/site
>     /opt/rakudo-pkg/share/perl6/vendor
>     /opt/rakudo-pkg/share/perl6
>     CompUnit::Repository::AbsolutePath<53332448>
>     CompUnit::Repository::NQP<47798144>
>     CompUnit::Repository::Perl5<47798184>
>
>
> This works:
> $ p6 'use lib "/home/linuxutil"; use PrintColors; PrintRed "Hi\n";'
> Hi
>
> But how do I get it into the "-M"?
>
> Many thanks,
> -T


I need -M help

2018-09-14 Thread Todd Chester

Hi All,

With a one liner, how to I load a module that resides in the
current directory?

$ ls PrintColors.pm6
PrintColors.pm6


$ perl6 -MPrintColors -e 'PrintRed "Hi";'
===SORRY!===
Could not find PrintColors at line 1 in:
/home/tony/.perl6
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6
CompUnit::Repository::AbsolutePath<58670368>
CompUnit::Repository::NQP<53138976>
CompUnit::Repository::Perl5<53139016>


$ perl6 -M./PrintColors -e 'PrintRed "Hi";'
===SORRY!===
Could not find ./PrintColors at line 1 in:
/home/tony/.perl6
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6
CompUnit::Repository::AbsolutePath<53332448>
CompUnit::Repository::NQP<47798144>
CompUnit::Repository::Perl5<47798184>


This works:
$ p6 'use lib "/home/linuxutil"; use PrintColors; PrintRed "Hi\n";'
Hi

But how do I get it into the "-M"?

Many thanks,
-T


Re: .kv ?

2018-09-14 Thread Todd Chester
On Fri, 14 Sep 2018, 11:22 Todd Chester, > wrote:


Hi All,

I adore the "kv" method:

$ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i  $j" };'
0  abc
1  23
2  4.56

So, I decided to go and look at:
https://docs.perl6.org/routine/kv

multi method kv(Any:U:  -->List)
multi method kv(Any:D:  -->List)


Okay, here is what I see:

"method"  is .foo style of a routine

"Any:U:" and "Any:D:" are what goes in front of .foo
and it can be of type "Any".

https://docs.perl6.org/type/Any

   ":D" mean constrained, meaning it much have something

   What is ":U"?

   Whatever ":U", how can it be both?

The second ":" is the delimiter for what goes in front of the .foo,
meaning it has finished its declaration of what that in front is.
Kind of like a comma.

"-->List" mean something is returned of type "List"
https://docs.perl6.org/type/List

   0  abc
   1  23
   2  4.56


How have I done so far?


And is there a list somewhere of the meanings of ":U" and ":D"
and such so the next time I see one that I do not recognize,
I can look it up?

Many thanks,
-T




On 09/14/2018 03:28 AM, Simon Proctor wrote:
:D means a defined value. So it's when you have an instance. :U is 
undefined so it's when you call kv as a classethod.


Pair.kv would be :U.
(A => "b").kv would be :D




Hi Simion,

I am not following.  What do you mean by "undefined"?

I can't make head or tails out of "Pair"
https://docs.perl6.org/type/Pair

I thought ":D" meant "constrained"?

Yours in confusion ,
-T


Re: .new?

2018-09-14 Thread Timo Paulssen
The doc website creates the pages under "routine/" by collecting every
type's methods and relevant subs of that name and putting them all on a
page.

It's a very unfortunate accident that the one for Telemetry::Sampler
ends up at the top, because right below that is the one for Mu, which is
the most general one that also links to the "documentation on object
construction" where things are explained clearly in a tutorial style.

Telemetry::Sampler isn't a routine, it's a class. You can follow the
link labelled "from Telemetry::Sampler" to get to the documentation of
the class by that name, which explains what it is, how you get it, and
how you use it.

I'll file a bug for the "new" routine page.

Hope that helps!
  - Timo

On 14/09/2018 12:30, Todd Chester wrote:
> Hi All,
>
> What exactly is going on with .new?
>
>   https://docs.perl6.org/routine/new
>   method new(Telemetry::Sampler: @instruments --> Telemetry::Sampler:D)
>
> The whole thing went over my head.  It looks like
> specifications for the developers, but I really can't
> tell.  And it looks like it might be really handy.
>
> What can I use it for?
>
>
> Also, does "Telemetry::Sampler" mean what it does in Perl 5,
> which is a routine called "Sampler" found in the module
> called "Telemetry"?
>
> Many thanks,
> -T


Re: .new?

2018-09-14 Thread Elizabeth Mattijsen
Good catch!

I think that one is worth a documentation issue.  The perl6doc builder gathered 
information about all “new” methods it could find *without any context*, and 
put them into one file.  For a method such as “new” not the best thing to do.  
I would argue that this page should be replaced by an ad-hoc page explaining 
the default way how the “new” method works.

In any case, Telemetry::Sampler should *not* be the entry on this page.

> On 14 Sep 2018, at 12:30, Todd Chester  wrote:
> 
> Hi All,
> 
> What exactly is going on with .new?
> 
>  https://docs.perl6.org/routine/new
>  method new(Telemetry::Sampler: @instruments --> Telemetry::Sampler:D)
> 
> The whole thing went over my head.  It looks like
> specifications for the developers, but I really can't
> tell.  And it looks like it might be really handy.
> 
> What can I use it for?
> 
> 
> Also, does "Telemetry::Sampler" mean what it does in Perl 5,
> which is a routine called "Sampler" found in the module
> called "Telemetry"?
> 
> Many thanks,
> -T


Re: .new?

2018-09-14 Thread Simon Proctor
I think the docs of objects (sorry on my phone no link) describe object
creation and the default new quite well.

Do a search for objects.

On Fri, 14 Sep 2018, 11:30 Todd Chester,  wrote:

> Hi All,
>
> What exactly is going on with .new?
>
>https://docs.perl6.org/routine/new
>method new(Telemetry::Sampler: @instruments --> Telemetry::Sampler:D)
>
> The whole thing went over my head.  It looks like
> specifications for the developers, but I really can't
> tell.  And it looks like it might be really handy.
>
> What can I use it for?
>
>
> Also, does "Telemetry::Sampler" mean what it does in Perl 5,
> which is a routine called "Sampler" found in the module
> called "Telemetry"?
>
> Many thanks,
> -T
>


.new?

2018-09-14 Thread Todd Chester

Hi All,

What exactly is going on with .new?

  https://docs.perl6.org/routine/new
  method new(Telemetry::Sampler: @instruments --> Telemetry::Sampler:D)

The whole thing went over my head.  It looks like
specifications for the developers, but I really can't
tell.  And it looks like it might be really handy.

What can I use it for?


Also, does "Telemetry::Sampler" mean what it does in Perl 5,
which is a routine called "Sampler" found in the module
called "Telemetry"?

Many thanks,
-T


Re: .kv ?

2018-09-14 Thread Simon Proctor
:D means a defined value. So it's when you have an instance. :U is
undefined so it's when you call kv as a classethod.

Pair.kv would be :U.
(A => "b").kv would be :D


On Fri, 14 Sep 2018, 11:22 Todd Chester,  wrote:

> Hi All,
>
> I adore the "kv" method:
>
> $ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i  $j" };'
> 0  abc
> 1  23
> 2  4.56
>
> So, I decided to go and look at:
> https://docs.perl6.org/routine/kv
>
> multi method kv(Any:U:  -->List)
> multi method kv(Any:D:  -->List)
>
>
> Okay, here is what I see:
>
> "method"  is .foo style of a routine
>
> "Any:U:" and "Any:D:" are what goes in front of .foo
> and it can be of type "Any".
>
>   https://docs.perl6.org/type/Any
>
>   ":D" mean constrained, meaning it much have something
>
>   What is ":U"?
>
>   Whatever ":U", how can it be both?
>
> The second ":" is the delimiter for what goes in front of the .foo,
> meaning it has finished its declaration of what that in front is.
> Kind of like a comma.
>
> "-->List" mean something is returned of type "List"
>   https://docs.perl6.org/type/List
>
>   0  abc
>   1  23
>   2  4.56
>
>
> How have I done so far?
>
>
> And is there a list somewhere of the meanings of ":U" and ":D"
> and such so the next time I see one that I do not recognize,
> I can look it up?
>
> Many thanks,
> -T
>


.kv ?

2018-09-14 Thread Todd Chester

Hi All,

I adore the "kv" method:

$ p6 'for "abc\n23\n4.56".lines.kv -> $i, $j { say "$i  $j" };'
0  abc
1  23
2  4.56

So, I decided to go and look at:
   https://docs.perl6.org/routine/kv

multi method kv(Any:U:  -->List)
multi method kv(Any:D:  -->List)


Okay, here is what I see:

"method"  is .foo style of a routine

"Any:U:" and "Any:D:" are what goes in front of .foo
and it can be of type "Any".

 https://docs.perl6.org/type/Any

 ":D" mean constrained, meaning it much have something

 What is ":U"?

 Whatever ":U", how can it be both?

The second ":" is the delimiter for what goes in front of the .foo,
meaning it has finished its declaration of what that in front is.
Kind of like a comma.

"-->List" mean something is returned of type "List"
 https://docs.perl6.org/type/List

 0  abc
 1  23
 2  4.56


How have I done so far?


And is there a list somewhere of the meanings of ":U" and ":D"
and such so the next time I see one that I do not recognize,
I can look it up?

Many thanks,
-T


Re: Please explain this to me

2018-09-14 Thread Todd Chester




On 09/13/2018 10:24 PM, JJ Merelo wrote:
Last time I counted, there were a dozen comments and 3 commits in the 
issue I created to try and improve the description. 2 files were 
modified by me. 


Is there some where I can look at these comments?


That's rather a dynamic way of not budging.


True.  I was over reacting


Re: Please explain this to me

2018-09-14 Thread Todd Chester




On 09/12/2018 12:19 AM, Simon Proctor wrote:
In answer to "why the : between Str:D and Cool:D and why Int(Cool:D) ?" 
can I just point out the video I linked (or the slides) which answer 
both of these questions.


Hi Simon,

Larry Wall, who has a unique gift for making the complex
easy, explained it to me this way:

 On 09/12/2018 10:34 AM, Larry Wall wrote:

 That is the wrong direction to think about it.  Int is not
 being redefined as Cool:D there.  The basic type there is
 just Int, and when the $pos comes in, it will end up being
 a simple Int.  This syntax is called a "coercion type", and
 it just says that we can also accept anything that matches
 Cool:D and turn it into an Int.  But the inside of the
 method knows nothing about the Cool:D part.

 Think of Int(Cool:D) as the signature matcher automatically
 applying the normal Int($coolthing) coercer for you to
 make sure you have an Int, precisely so that you *don't*
 have to worry about the Cool:D part inside the routine,
 but know that it simply an Int for any part of the routine
 after the signature.


multi method contains(Str:D: Cool:D $needle, Int(Cool:D) $pos) --> Bool

$ p6 'say "abc234.56".contains( 2, "1" );' # Str changed to an Int
True

$ p6 'say "abc234.56".contains( 2, 2.4 );' # Real changed to an Int
True