Re: my first two doc issues

2020-01-20 Thread Philip Hazelden
On Tue, Jan 21, 2020, 12:16 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

They did not give me
> the link to report it.
>

JJ's very first comment: "You would probably want to raise this issue in
the zef repo itself ." The words "zef repo
itself" are the link to the place to report.

Wait, one minute I am offering insult, the next I am offering harm?  Get
> your garbage straight.


Not all insults cause harm, and not all harm comes from insults. Also, not
all harm caused by insults is caused to the people insulted.

And so when I say "harm" I am making an separate, additional claim to when
I say "insult". Both are true.

You are insulting the maintainers: whether you intend to or not, whether
you realize it it not. And this is harmful: for one example, even if the
specific targets of your attack don't take offense, anyone who reads it and
would have taken offense in their shoes becomes less likely to take on a
maintainership role in future.


Re: My Windows Modules

2020-01-20 Thread ToddAndMargo via perl6-users

Hi All,

I have my Win API modules to the point I
like them now.  I will be a few months
before I get them up on GIT.

If anyone wants to look at them now, I will
vpaste.net them for you.

:-)

-T


Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 20:36, 浪花城主 wrote:

How about returning a reference?

Just for test (sorry I have no perl6 installed on local device):

$ perl -le 'sub x {%hash=(1,2,3,4);\%hash}; print x->{1}'
2

Regards.


Hi 浪花城主,

No Perl6 installed  I am Heart Broken!!!  Why!
Why!  KIDS THESE DAYS!!

:-)

I do not understand what you mean by "reference"?

Do you mean the key(s)?

> say x.keys
(A)
> sub x() returns Hash { my %h= A=>"a", B=>"b"; return %h}

> say x.keys
(B A)
> say x
b

Be aware that they are not stored in the order you
place them.  I have no clue why.

In Perl 5, we have a think called "reference".
It is a structure that points to another structure.
Basically, it a C Pointer on steroids.  Perl 6 has
no such animal as it does not need one (YIPPEE!!).

-T


Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread 浪花城主
How about returning a reference?

Just for test (sorry I have no perl6 installed on local device):

$ perl -le 'sub x {%hash=(1,2,3,4);\%hash}; print x->{1}'
2

Regards.

On Tue, Jan 21, 2020 at 11:56 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> What is the proper way to state that I am returning a
> hash from a sub?   `sub x() returns % {}`
>
> And an array?  `sub x() returns @ {}`
>
> Many thanks,
> -T
>


Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 20:09, ToddAndMargo via perl6-users wrote:

On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote:

Hi All,

What is the proper way to state that I am returning a
hash from a sub?   `sub x() returns % {}`

And an array?  `sub x() returns @ {}`

Many thanks,
-T



I think this is it:

 > sub x() returns Associative { my %h= A=>"a"; return %h}

 > x
{A => a}


Yup, too high up the food chain:

> sub x() returns Hash { my %h= A=>"a"; return %h}

> x
{A => a}





 > sub y() returns Array { my @a=(1,2,3,2,1) ; return @a}

 > y
[1 2 3 2 1]


Am I too high up the food chain with Associative and Array?

-T



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


Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote:

Hi All,

What is the proper way to state that I am returning a
hash from a sub?   `sub x() returns % {}`

And an array?  `sub x() returns @ {}`

Many thanks,
-T



I think this is it:

> sub x() returns Associative { my %h= A=>"a"; return %h}

> x
{A => a}


> sub y() returns Array { my @a=(1,2,3,2,1) ; return @a}

> y
[1 2 3 2 1]


Am I too high up the food chain with Associative and Array?

-T


I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users

Hi All,

What is the proper way to state that I am returning a
hash from a sub?   `sub x() returns % {}`

And an array?  `sub x() returns @ {}`

Many thanks,
-T


Re: Rough first draft of Native Call WinAPI

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 19:30, 浪花城主 wrote:

Hi ToddAndMargo

I would like to see that. Thanks.

On Tue, Jan 21, 2020 at 10:59 AM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


Hi All,

I have a first rough draft of my "T’s Reference on
Raku’s NativeCall and Win API calls" ready
to go.

If you are interested, I will eMail it to you.  It is in
Open Document Text (ODT) format (Libre Office).

I would love a good peer review.

-T



On its way!

Let me know your technical opinion please


Re: Rough first draft of Native Call WinAPI

2020-01-20 Thread 浪花城主
Hi ToddAndMargo

I would like to see that. Thanks.

On Tue, Jan 21, 2020 at 10:59 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> I have a first rough draft of my "T’s Reference on
> Raku’s NativeCall and Win API calls" ready
> to go.
>
> If you are interested, I will eMail it to you.  It is in
> Open Document Text (ODT) format (Libre Office).
>
> I would love a good peer review.
>
> -T
>


Rough first draft of Native Call WinAPI

2020-01-20 Thread ToddAndMargo via perl6-users

Hi All,

I have a first rough draft of my "T’s Reference on
Raku’s NativeCall and Win API calls" ready
to go.

If you are interested, I will eMail it to you.  It is in
Open Document Text (ODT) format (Libre Office).

I would love a good peer review.

-T


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Elizabeth Mattijsen
> On 21 Jan 2020, at 01:01, Norman Gaywood  wrote:
> On Tue, 21 Jan 2020 at 03:12, Brad Gilbert  wrote:
> .say for lines
> 
> Since .say calls gist(), would it be not be better/safer to call .put instead?
> 
>.put for lines 

Since lines only produces Str objects, and both Str.Str and Str.gist are noops, 
it doesn't make any difference?


Liz

Re: my first two doc issues

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 16:02, Philip Hazelden wrote:



On Mon, Jan 20, 2020, 11:48 PM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


On 2020-01-20 15:23, Philip Hazelden wrote:
 > Since you continue to insult the maintainers,



What a bunch of crap!  It was only one person
and I don't think he meant any harm.




I never said you thought anyone meant harm. I said you offered insult.


Stop slicing the baloney!  Offerig insult is harm.  and
I did no such thing.



And if you had actually read the link,



I read it. If you think you are so obviously in the right that anyone 
who reads the link will clearly agree with you, you think wrong.



If you post something on your download
page that has an issue, 




It did not.


You obvious did not read it.



OR ask the reporter to do so and where (as
the reported has no idea where you got it from),
which I would have gladly done, as I did with
WoeUSB over on Fedora.



You were asked. You did not do so.


They told not their problem.  One individual was
prolific in his defense.  They did not give me
the link to report it.

Imagine if you will, a Raku download site that downloads
a version of Raku THAT WON'T RUN and IT'S NOT THEIR
PROBLEM.


Did you even read the Fedora post to see how it
should have been done?



Yes. The difference is not entirely in your response, but that is the 
main difference.


Fedora was very professional.


Geez Philip!  Why are you trying to find harm
where there is none!




There is harm.


Wait, one minute I am offering insult, the next I am offering harm?  Get 
your garbage straight.




I have no expectation that I can convince you of any of this. 
Nevertheless, it felt important to say.

Ya.  The world takes all types.


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 19:03 Trey Harris  wrote:

> On Mon, Jan 20, 2020 at 02:59 William Michels via perl6-users <
> perl6-us...@perl.org> wrote:
>
>> Hi Yary (and Todd),
>>
>> Thank you both for your responses. Yary, the problem seems to be with
>> "get". I can change 'while' to 'for' below, but using 'get' raku/perl6
>> actually returns fewer lines with "for" than it did with "while":
>
>
> If you want to do line-oriented input, use `.lines` with `for`; it returns
> something `for` can iterate over.
>

Sorry, in a setting where a handle isn’t the context, I meant `lines`, not
`.lines`, though I was referring _to_ a thing called `.lines`, the multi
method. I don’t think we’ve all yet agreed on how multis that can be called
as plain routines should be referred to in umbrella term. `.lines` is more
“correct”, but it’s less likely to actually work without understanding
more, which is a strange conundrum for documentation.

Trey


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 19:01 Norman Gaywood  wrote:

>
> On Tue, 21 Jan 2020 at 03:12, Brad Gilbert  wrote:
>
>> .say for lines
>>
>
> Since .say calls gist(), would it be not be better/safer to call .put
> instead?
>
>.put for lines
>

If being set directly from `lines`, I can’t see when there would be a
difference unless you’re playing with encodings. If you entire program is
just this, they’re the same for normal Unix files. (I have no idea what
happens in the case of sparse files, abnormal files, devices, etc.)

And “safer” is in the eye of the beholder... if you’re outputting
diagnostics for immediate human consumption, a gist is less likely to ruin
formatted output.

Trey


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 02:59 William Michels via perl6-users <
perl6-us...@perl.org> wrote:

> Hi Yary (and Todd),
>
> Thank you both for your responses. Yary, the problem seems to be with
> "get". I can change 'while' to 'for' below, but using 'get' raku/perl6
> actually returns fewer lines with "for" than it did with "while":


If you want to do line-oriented input, use `.lines` with `for`; it returns
something `for` can iterate over.

`.get` is the wrong tool for the job; it returns a single line. To get all
lines, you must call it repeatedly; so you’d need to run an infinite loop
(either using `loop`, `while` with a true value, or `for` with a
never-ending sequence) and break out when you reach the end of the file.

This _works_ just fine, but it’s very weird:

perl6 -e 'loop { last if $*IN.eof; $_ = $*IN.get; .say }' < abc_def.text

You’d typically use “get” in a case where you’re doing low-level I/O, not
for writing a POSIX-like line-oriented filter.  `for lines -> $line { ...
}` is what you want in programs, but `.say for lines` (or put instead of
say, they’re equivalent here) in a one-liner.

>


Re: my first two doc issues

2020-01-20 Thread Philip Hazelden
On Mon, Jan 20, 2020, 11:48 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2020-01-20 15:23, Philip Hazelden wrote:
> > Since you continue to insult the maintainers,
>
> What a bunch of crap!  It was only one person
> and I don't think he meant any harm.
>

I never said you thought anyone meant harm. I said you offered insult.

And if you had actually read the link,


I read it. If you think you are so obviously in the right that anyone who
reads the link will clearly agree with you, you think wrong.

If you post something on your download
> page that has an issue,


It did not.

OR ask the reporter to do so and where (as
> the reported has no idea where you got it from),
> which I would have gladly done, as I did with
> WoeUSB over on Fedora.


You were asked. You did not do so.

Did you even read the Fedora post to see how it
> should have been done?
>

Yes. The difference is not entirely in your response, but that is the main
difference.

Geez Philip!  Why are you trying to find harm
> where there is none!
>

There is harm.

I have no expectation that I can convince you of any of this. Nevertheless,
it felt important to say.


> -T
>


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Norman Gaywood
On Tue, 21 Jan 2020 at 03:12, Brad Gilbert  wrote:

> .say for lines
>

Since .say calls gist(), would it be not be better/safer to call .put
instead?

   .put for lines

-- 
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngayw...@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


Re: my first two doc issues

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 15:23, Philip Hazelden wrote:
Since you continue to insult the maintainers, 


What a bunch of crap!  It was only one person
and I don't think he meant any harm.

And if you had actually read the link, you
would have found that its was a "maintainer"
I am suppose to be dissing that solved the
issue.

I will step in to defend them: 


And I will defend myself.

the response you got to 145 was perfectly reasonable. You were 
told that you opened it in the wrong place, which you argued with, and 
you were told where you should have opened it instead, which you 
ignored. The problem was you.


If you post something on your download
page that has an issue, you either remove it from
your site OR you notify upstream of the problem
OR ask the reporter to do so and where (as
the reported has no idea where you got it from),
which I would have gladly done, as I did with
WoeUSB over on Fedora.

Did you even read the Fedora post to see how it
should have been done?

The problem was not me, but one person acting
unprofessionally and only in that instance.  And I
do not think he meant any harm, I just think
he just did not know any better.  I had a
conversation with him about it.

Geez Philip!  Why are you trying to find harm
where there is none!

-T


Re: my first two doc issues

2020-01-20 Thread Philip Hazelden
Since you continue to insult the maintainers, I will step in to defend
them: the response you got to 145 was perfectly reasonable. You were told
that you opened it in the wrong place, which you argued with, and you were
told where you should have opened it instead, which you ignored. The
problem was you.

On Mon, Jan 20, 2020, 6:29 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 2020-01-19 15:09, Tobias Boege wrote:
> > On Sun, 19 Jan 2020, ToddAndMargo via perl6-users wrote:
> >> RFE: Please add the following examples to routine +^
> >> https://github.com/Raku/doc/issues/3177
> >>
> >> Now I wait and see what kind of reception I get.  It
> >> will be nice to contribute to the docs, rather than
> >> just always griping about them
> >>
> >
> > Oh well, I just responded with what my gut told me when this arrived
> > in my inbox. Didn't know that I would be part of a public experiment.
> >
> > Anyway, godspeed!
> >
> > Regards,
> > Tobias
> >
>
> Hi Tobias,
>
> So far I am absolutely tickled over the
> thoughtful and constructive responses I have
> been seeing, yours being one of them.
>
> This is the reception I was afraid of:
> https://github.com/rakudo/star/issues/145
>
> And so far not a sign of 145's response/culture.
>
> This is an example of how issue 145 above should
> have been handled (my bug report as well):
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1773142
> 1) I reported the bug
> 2) they told me to go to upstream and where
> 3) I opened the bug on to upstream, reported it
>back to Fedora, Fedora kept the bug open
> 4) upstream resolved the issue, Fedora patched
>the program under the original bug.
> 5) joy.  ZERO ARGUING.  Very professional.
>
> I am looking forward to contributing more stuff
> in the future!
>
> :-)
>
> -T
>


Re: troubles with with base(2)

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 14:17, Tobias Boege wrote:

This is a truly beautiful and thoughtful thing about Raku.


The more I learn about Raku, the more it astounds me.
It is so well thought out, it is mesmerizing.

:-)


Re: non modal dialog?

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 13:08, ToddAndMargo via perl6-users wrote:

Hi All,

Is there a way to create a "non modal dialog" in
Raku for Windows?

Many thanks,
-T



One of the guys on the WinApi group gave me this:

Any idea how I do this is Raku?

-T

c++:

#include 
#include 
#include 

EXTERN_C int _tmain()
{
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED |
COINIT_DISABLE_OLE1DDE);
IProgressDialog* pDlg = nullptr;

if(SUCCEEDED(CoCreateInstance(CLSID_ProgressDialog, nullptr,
CLSCTX_SERVER, IID_IProgressDialog, reinterpret_cast(
{
pDlg->StartProgressDialog(nullptr, nullptr, PROGDLG_NORMAL |
PROGDLG_AUTOTIME, nullptr);

for(unsigned percent = 0; percent <= 100; ++percent)
{
if(pDlg->HasUserCancelled())
break;

pDlg->SetProgress(percent, 100);
Sleep(1000);
}

pDlg->StopProgressDialog();
pDlg->Release();
}

CoUninitialize();
}


Re: troubles with with base(2)

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 14:17, Tobias Boege wrote:

^ is a junction constructor, specifically it creates a one() junction.
If you want bitwise XOR use the... bitwise XOR operator +^.



I left off the +.

Mumble, mumble

:'(


Re: troubles with with base(2)

2020-01-20 Thread ToddAndMargo via perl6-users
On Mon, Jan 20, 2020 at 3:57 PM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


Hi All,

Now what am I doing wrong?

  my $v = 0b00101101 ^ 0b1001; say $v.base(2);
  one(101101, 1001)

It should be
  100100


Many thanks,
-T



On 2020-01-20 14:21, Brad Gilbert wrote:

Why would you think that?

The numeric binary xor operator is +^.

     my $v = 0b00101101 +^ 0b1001; say $v.base(2);
     # 100100

^ is the junctive xor operator.

    my $v = 1 ^ 2 ^ 'a';
   $v eq 'a'; # True
   $v == 1; # True
   $v == 2; # True
   $v == 3; # False

There is also the stringy binary xor operator.

     say 'A' ~^ '%'; # D


Ah poop!  I forgot the +

Thanks for the second pair of eye!

Much better:
my $v = 0b00101101 +^ 0b1001; say $v.base(2);
100100


Re: troubles with with base(2)

2020-01-20 Thread Brad Gilbert
Why would you think that?

The numeric binary xor operator is +^.

my $v = 0b00101101 +^ 0b1001; say $v.base(2);
# 100100

^ is the junctive xor operator.

   my $v = 1 ^ 2 ^ 'a';
  $v eq 'a'; # True
  $v == 1; # True
  $v == 2; # True
  $v == 3; # False

There is also the stringy binary xor operator.

say 'A' ~^ '%'; # D

On Mon, Jan 20, 2020 at 3:57 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> Now what am I doing wrong?
>
>  my $v = 0b00101101 ^ 0b1001; say $v.base(2);
>  one(101101, 1001)
>
> It should be
>  100100
>
>
> Many thanks,
> -T
>


Re: troubles with with base(2)

2020-01-20 Thread Tobias Boege
On Mon, 20 Jan 2020, ToddAndMargo via perl6-users wrote:
> Hi All,
> 
> Now what am I doing wrong?
> 
> my $v = 0b00101101 ^ 0b1001; say $v.base(2);
> one(101101, 1001)
> 
> It should be
> 100100
> 

Please examine the output you get. Does the spurious "one" in there not
make you raise an eyebrow and head over to the documentation?

^ is a junction constructor, specifically it creates a one() junction.
If you want bitwise XOR use the... bitwise XOR operator +^.

In general, the "bare" operators &, |, ^ in Raku are used for declarative
purposes: in normal Raku they are junction constructors and in regexes
they denote longest-token matching.

Many other languages use these operators for (signed or unsigned) bitwise
operations, but in Raku these "numeric" bitwise operations are put under
the "+" umbrella to show that they are numeric: +&, +| and +^. Corresponding
operators also exist for buffers as ~&, ~| and ~^, for booleans as ?&, ?|
and ?^ and for sets as (&), (|), (^).

This is a truly beautiful and thoughtful thing about Raku.

Regards,
Tobias

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk


troubles with with base(2)

2020-01-20 Thread ToddAndMargo via perl6-users

Hi All,

Now what am I doing wrong?

my $v = 0b00101101 ^ 0b1001; say $v.base(2);
one(101101, 1001)

It should be
100100


Many thanks,
-T


Re: definition confusion of + and +^

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-20 08:32, Peter Pentchev wrote:

On Sun, Jan 19, 2020 at 08:25:15PM -0800, ToddAndMargo via perl6-users wrote:

One last question on htis.  What does

multi sub prefix:<+^>(Any --> Int:D)

Mean.  Prefix means before.  +^(Any) get
me a participation trophy, so I do not
understand.


:'(

INQUIRING MINDS WANT TO KNOW! (That is
a joke referencing a tabloid commercial.)


The <> characters surround the name of the operator, so the operator is
named "+^". This means that you would use it on $foo as:

 $something = +^$foo;

The part in the parentheses is a description of what arguments this
function (the operator that we are now describing in terms of functions)
will take and what type it will return. The part before the --> sign is
what arguments it takes - in this case it takes a single argument that
must be of the Any type or one of its subtypes, so pretty much anything
(yeah, yeah, I know) in Raku may be used as an argument to this
operator. The part after the --> sign describes the type of the value
that the function (the +^ operator) will return - it says that the
returned value will be an integer and that it will always have a
definite value, it will not be an undefined value.

So this means that whatever you have in a variable $foo, you may write
+^$foo and you will get an integer.

G'luck,
Peter



Hi Peter,

Thank you!

I guess there is no way to keep that from screwing with my
variable definition if it --> Int:D

$ p6 'my UInt $x =  +^0b1001; '
Type check failed in assignment to $x; expected UInt but got Int (-10)
  in block  at -e line 1

Ordinarily, I like this feature, but there
are times it is a pain in the ...

Work arounds:

$ p6 'my byte $x =  +^0b1001; say $x.base(2)'
0110

$ p6 'constant WORD := uint16; my WORD $x =  +^0b1001; say $x.base(2)'
0110


-T


non modal dialog?

2020-01-20 Thread ToddAndMargo via perl6-users

Hi All,

Is there a way to create a "non modal dialog" in
Raku for Windows?

Many thanks,
-T


Re: my first two doc issues

2020-01-20 Thread ToddAndMargo via perl6-users

On 2020-01-19 15:09, Tobias Boege wrote:

On Sun, 19 Jan 2020, ToddAndMargo via perl6-users wrote:

RFE: Please add the following examples to routine +^
https://github.com/Raku/doc/issues/3177

Now I wait and see what kind of reception I get.  It
will be nice to contribute to the docs, rather than
just always griping about them



Oh well, I just responded with what my gut told me when this arrived
in my inbox. Didn't know that I would be part of a public experiment.

Anyway, godspeed!

Regards,
Tobias



Hi Tobias,

So far I am absolutely tickled over the
thoughtful and constructive responses I have
been seeing, yours being one of them.

This is the reception I was afraid of:
https://github.com/rakudo/star/issues/145

And so far not a sign of 145's response/culture.

This is an example of how issue 145 above should
have been handled (my bug report as well):

https://bugzilla.redhat.com/show_bug.cgi?id=1773142
   1) I reported the bug
   2) they told me to go to upstream and where
   3) I opened the bug on to upstream, reported it
  back to Fedora, Fedora kept the bug open
   4) upstream resolved the issue, Fedora patched
  the program under the original bug.
   5) joy.  ZERO ARGUING.  Very professional.

I am looking forward to contributing more stuff
in the future!

:-)

-T


Re: Ping JJ: string literals

2020-01-20 Thread Peter Pentchev
On Sun, Jan 19, 2020 at 12:20:18AM -0500, Paul Procacci wrote:
> On Sun, Jan 19, 2020 at 12:12 AM yary  wrote:
> 
> > In UTF-16 every character is 16 bits, so all 8 bits of zeros tells you is
> > that it's possibly a big-endian ascii character or a little-endian
> > non-ascii character at a position divisible by 256. All zeros U+ is
> > unicode NULL, which the windows UTF-16 C convention uses to terminate the
> > string.
> 
> Perfect.  Obviously didn't know that.  My assumption that only the first
> byte gets checked was obviously wrong.

It is correct if you're talking about UTF-8, not UTF-16 :)

G'luck,
Peter

-- 
Peter Pentchev  roam@{ringlet.net,debian.org,FreeBSD.org} p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: definition confusion of + and +^

2020-01-20 Thread Peter Pentchev
On Sun, Jan 19, 2020 at 08:25:15PM -0800, ToddAndMargo via perl6-users wrote:
> One last question on htis.  What does
> 
> multi sub prefix:<+^>(Any --> Int:D)
> 
> Mean.  Prefix means before.  +^(Any) get
> me a participation trophy, so I do not
> understand.
> 
> 
> :'(
> 
> INQUIRING MINDS WANT TO KNOW! (That is
> a joke referencing a tabloid commercial.)

The <> characters surround the name of the operator, so the operator is
named "+^". This means that you would use it on $foo as:

$something = +^$foo;

The part in the parentheses is a description of what arguments this
function (the operator that we are now describing in terms of functions)
will take and what type it will return. The part before the --> sign is
what arguments it takes - in this case it takes a single argument that
must be of the Any type or one of its subtypes, so pretty much anything
(yeah, yeah, I know) in Raku may be used as an argument to this
operator. The part after the --> sign describes the type of the value
that the function (the +^ operator) will return - it says that the
returned value will be an integer and that it will always have a
definite value, it will not be an undefined value.

So this means that whatever you have in a variable $foo, you may write
+^$foo and you will get an integer.

G'luck,
Peter

-- 
Peter Pentchev  roam@{ringlet.net,debian.org,FreeBSD.org} p...@storpool.com
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13


signature.asc
Description: PGP signature


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Brad Gilbert
.say for lines

On Mon, Jan 20, 2020 at 1:59 AM William Michels via perl6-users <
perl6-us...@perl.org> wrote:

> Hi Yary (and Todd),
>
> Thank you both for your responses. Yary, the problem seems to be with
> "get". I can change 'while' to 'for' below, but using 'get' raku/perl6
> actually returns fewer lines with "for" than it did with "while":
>
> [1]mydir$ cat testthis_abc_def.txt
> a
> b
> c
>
> d
> e
> f
> [2]mydir$ perl6 -e '.say while $_ = $*IN.get;' < testthis_abc_def.txt
> a
> b
> c
> [3]mydir$ perl6 -e '.say for $_ = $*IN.get;' < testthis_abc_def.txt
> a
>
> I assumed 'get' was looking at EOF but that's incorrect--apparently
> 'get' acts more like a glorified call to lines[0], reading one line of
> an input file and then stopping. I can read my whole test file by
> explicitly testing for EOF (note the redeclaration of $*IN below).
> Otherwise, my best course of action is replacing 'get' with 'lines',
> and using either 'while' or 'for' ('.say for $*IN.lines;' replicates
> 'cat' behavior the best):
>
> [4]mydir$ perl6 -e 'while not($*IN.eof) -> {$*IN.get.say };' <
> testthis_abc_def.txt
> a
> b
> c
>
> d
> e
> f
> [5]mydir$ perl6 -e '.say while $_ =$*IN.lines;' < testthis_abc_def.txt
> (a b c  d e f)
> [6]mydir$ perl6 -e '.say for $_ = $*IN.lines;' < testthis_abc_def.txt
> (a b c  d e f)
> [7]mydir$ perl6 -e '.say for $*IN.lines;' < testthis_abc_def.txt
> a
> b
> c
>
> d
> e
> f
>
> HTH, Bill.
>
>
>
>
>
> On Sat, Jan 18, 2020 at 5:55 PM yary  wrote:
> >
> > "while" is the wrong looping construct for going over file lines, and
> that's across a great many computer languages. It will stop when it
> encounters a false line- typically an empty line or '0'
> >
> > Try "for"
> >
> > -y
> >
> >
> > On Sat, Jan 18, 2020 at 4:45 PM William Michels 
> wrote:
> >>
> >> Hello All,
> >>
> >> I've been reviewing literature that discusses using raku/perl6 as a
> >> replacement for common unix utilities. One important unix utility is
> >> "cat". I looked at docs/blogs and found a recommendation to use "$*IN"
> >> along with "slurp" (references at bottom). Using a seven-line test
> >> file "testthis_abc_def.txt" below (1), the recommended "slurp" code
> >> works as expected (2).
> >>
> >> However, another recommendation to use "$*IN" along with the "get"
> >> method fails when a blank line is encountered, only returning
> >> truncated output (3). I tried correcting truncated output seen with
> >> "get" by playing with the command-line arguments "-ne" (4) and "-pe"
> >> (5), but only ended up mangling output even further.
> >>
> >> Can "get" be used in when writing raku/perl6 replacement code for "cat"?
> >>
> >> Any advice appreciated,
> >>
> >> Bill.
> >>
> >>
> >> [1]mydir$ cat testthis_abc_def.txt
> >> a
> >> b
> >> c
> >>
> >> d
> >> e
> >> f
> >> [2]mydir$ perl6 -e 'say $*IN.slurp;' < testthis_abc_def.txt
> >> a
> >> b
> >> c
> >>
> >> d
> >> e
> >> f
> >>
> >> [3]mydir$ perl6 -e '.say while $_ = $*IN.get;' < testthis_abc_def.txt
> >> a
> >> b
> >> c
> >> [4]mydir$ perl6 -ne '.say while $_ = $*IN.get;' < testthis_abc_def.txt
> >> b
> >> c
> >> e
> >> f
> >> [5]mydir$ perl6 -pe '.say while $_ = $*IN.get;' < testthis_abc_def.txt
> >> b
> >> c
> >>
> >> e
> >> f
> >> (Mu)
> >> [6]mydir$
> >>
> >>
> >> REFERENCES:
> >> 1. https://docs.raku.org/routine/slurp
> >> 2. https://docs.raku.org/routine/get
> >> 3.
> https://andrewshitov.com/2019/09/09/the-cat-utility-written-in-perl-6/
> >> 4.
> https://stackoverflow.com/questions/52597984/catching-exception-of-a-shell-command-in-perl-6
>


Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread William Michels via perl6-users
Hi Yary (and Todd),

Thank you both for your responses. Yary, the problem seems to be with
"get". I can change 'while' to 'for' below, but using 'get' raku/perl6
actually returns fewer lines with "for" than it did with "while":

[1]mydir$ cat testthis_abc_def.txt
a
b
c

d
e
f
[2]mydir$ perl6 -e '.say while $_ = $*IN.get;' < testthis_abc_def.txt
a
b
c
[3]mydir$ perl6 -e '.say for $_ = $*IN.get;' < testthis_abc_def.txt
a

I assumed 'get' was looking at EOF but that's incorrect--apparently
'get' acts more like a glorified call to lines[0], reading one line of
an input file and then stopping. I can read my whole test file by
explicitly testing for EOF (note the redeclaration of $*IN below).
Otherwise, my best course of action is replacing 'get' with 'lines',
and using either 'while' or 'for' ('.say for $*IN.lines;' replicates
'cat' behavior the best):

[4]mydir$ perl6 -e 'while not($*IN.eof) -> {$*IN.get.say };' <
testthis_abc_def.txt
a
b
c

d
e
f
[5]mydir$ perl6 -e '.say while $_ =$*IN.lines;' < testthis_abc_def.txt
(a b c  d e f)
[6]mydir$ perl6 -e '.say for $_ = $*IN.lines;' < testthis_abc_def.txt
(a b c  d e f)
[7]mydir$ perl6 -e '.say for $*IN.lines;' < testthis_abc_def.txt
a
b
c

d
e
f

HTH, Bill.





On Sat, Jan 18, 2020 at 5:55 PM yary  wrote:
>
> "while" is the wrong looping construct for going over file lines, and that's 
> across a great many computer languages. It will stop when it encounters a 
> false line- typically an empty line or '0'
>
> Try "for"
>
> -y
>
>
> On Sat, Jan 18, 2020 at 4:45 PM William Michels  wrote:
>>
>> Hello All,
>>
>> I've been reviewing literature that discusses using raku/perl6 as a
>> replacement for common unix utilities. One important unix utility is
>> "cat". I looked at docs/blogs and found a recommendation to use "$*IN"
>> along with "slurp" (references at bottom). Using a seven-line test
>> file "testthis_abc_def.txt" below (1), the recommended "slurp" code
>> works as expected (2).
>>
>> However, another recommendation to use "$*IN" along with the "get"
>> method fails when a blank line is encountered, only returning
>> truncated output (3). I tried correcting truncated output seen with
>> "get" by playing with the command-line arguments "-ne" (4) and "-pe"
>> (5), but only ended up mangling output even further.
>>
>> Can "get" be used in when writing raku/perl6 replacement code for "cat"?
>>
>> Any advice appreciated,
>>
>> Bill.
>>
>>
>> [1]mydir$ cat testthis_abc_def.txt
>> a
>> b
>> c
>>
>> d
>> e
>> f
>> [2]mydir$ perl6 -e 'say $*IN.slurp;' < testthis_abc_def.txt
>> a
>> b
>> c
>>
>> d
>> e
>> f
>>
>> [3]mydir$ perl6 -e '.say while $_ = $*IN.get;' < testthis_abc_def.txt
>> a
>> b
>> c
>> [4]mydir$ perl6 -ne '.say while $_ = $*IN.get;' < testthis_abc_def.txt
>> b
>> c
>> e
>> f
>> [5]mydir$ perl6 -pe '.say while $_ = $*IN.get;' < testthis_abc_def.txt
>> b
>> c
>>
>> e
>> f
>> (Mu)
>> [6]mydir$
>>
>>
>> REFERENCES:
>> 1. https://docs.raku.org/routine/slurp
>> 2. https://docs.raku.org/routine/get
>> 3. https://andrewshitov.com/2019/09/09/the-cat-utility-written-in-perl-6/
>> 4. 
>> https://stackoverflow.com/questions/52597984/catching-exception-of-a-shell-command-in-perl-6