Re: I need help with IO.e

2020-05-22 Thread ToddAndMargo via perl6-users

On 2020-05-19 05:17, Peter Pentchev wrote:


...control structures, I mean.

G'luck,
Peter



No problem,

I appreciate all the help!

:-)

-T


Re: I need help with IO.e

2020-05-19 Thread Peter Pentchev
On Tue, May 19, 2020 at 03:16:41PM +0300, Peter Pentchev wrote:
> On Mon, May 18, 2020 at 10:58:26PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-18 17:14, Peter Pentchev wrote:
> > > On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users 
> > > wrote:
> > > > In 2020-05-18 16:11, Peter Pentchev wrote:
> > > > > As an exercise for the reader: once the above sinks in, what exactly
> > > > > will "say if 'h:/'.IO.d" do?
> > > > 
> > > > It returns the the result of the expression that
> > > > "if" evaluated.
> > > 
> > > OK, so why does it give you an error message if you run it? :)
> > > 
> > > Not quite.
> > > 
> > >  say if 'h:/'.IO.d
> > > 
> > > ...is equivalent to:
> > > 
> > >  if 'h:/'.IO.d {
> > >  say;
> > >  }
> > > 
> > > which would have been valid in Perl (apart from the parentheses
> > > around the condition of the "if", Raku allows you to omit those), but
> > > it is not valid Raku. Run it and see what it says.
> > > 
> > > Once again you thought that "if" returns a value. "If" does not return
> > > a value, it is not a function, it is a statement. Just the same as "for"
> > > does not return a value, and "while" does not return a value.
> > > 
> > > G'luck,
> > > Peter
> > > 
> > 
> > Hi Peter,
> > 
> > Of course!  I am not arguing with anyone that
> > they are not right!
> > 
> > I am doing what I am doing to make things easier for
> > me to read in the future.  Since I am already using
> > a very high level language, what is one more affront
> > to my CPU?
> 
> Todd, I'm trying to tell you that you seem to misunderstand
> what "if" does. Please read my answer again: your idea of
> what "say if 'h:/'.IO.d" does is incorrect, "if" does not do
> what you think it does, and this is *essential* for understanding
> and writing Raku programs (or programs in pretty much any other
> language). Understanding the difference between functions and
> control statements is *essential*.

...control structures, I mean.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-19 Thread Peter Pentchev
On Mon, May 18, 2020 at 10:58:26PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-18 17:14, Peter Pentchev wrote:
> > On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > In 2020-05-18 16:11, Peter Pentchev wrote:
> > > > As an exercise for the reader: once the above sinks in, what exactly
> > > > will "say if 'h:/'.IO.d" do?
> > > 
> > > It returns the the result of the expression that
> > > "if" evaluated.
> > 
> > OK, so why does it give you an error message if you run it? :)
> > 
> > Not quite.
> > 
> >  say if 'h:/'.IO.d
> > 
> > ...is equivalent to:
> > 
> >  if 'h:/'.IO.d {
> >  say;
> >  }
> > 
> > which would have been valid in Perl (apart from the parentheses
> > around the condition of the "if", Raku allows you to omit those), but
> > it is not valid Raku. Run it and see what it says.
> > 
> > Once again you thought that "if" returns a value. "If" does not return
> > a value, it is not a function, it is a statement. Just the same as "for"
> > does not return a value, and "while" does not return a value.
> > 
> > G'luck,
> > Peter
> > 
> 
> Hi Peter,
> 
> Of course!  I am not arguing with anyone that
> they are not right!
> 
> I am doing what I am doing to make things easier for
> me to read in the future.  Since I am already using
> a very high level language, what is one more affront
> to my CPU?

Todd, I'm trying to tell you that you seem to misunderstand
what "if" does. Please read my answer again: your idea of
what "say if 'h:/'.IO.d" does is incorrect, "if" does not do
what you think it does, and this is *essential* for understanding
and writing Raku programs (or programs in pretty much any other
language). Understanding the difference between functions and
control statements is *essential*.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-19 Thread Tom Browder
On Tue, May 19, 2020 at 03:44 Richard Hainsworth 
wrote:

> The transcendental abundance of purple in Raku :)


Ah, Richard, thanks for a trip down memory lane! In my youth I discovered
the joys of science fiction a few years after that piece was published.

-Tom


Re: I need help with IO.e

2020-05-19 Thread Richard Hainsworth

Peter,

What a genius answer!

The transcendental abundance of purple in Raku :)

On 18/05/2020 22:26, Peter Pentchev wrote:
It's the internal representation of the program you told Raku to 
parse

and execute; the truth is that, just like in a sci-fi story about
a machine that is supposed to answer any question, but only comes back
with "the question has not been asked correctly", ...

In case anybody is curious,
http://www.gutenberg.org/cache/epub/33854/pg33854.txt

G'luck,
Peter



Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 22:58, ToddAndMargo via perl6-users wrote:

On 2020-05-18 17:14, Peter Pentchev wrote:
On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users 
wrote:

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.


OK, so why does it give you an error message if you run it? :)

Not quite.

 say if 'h:/'.IO.d

...is equivalent to:

 if 'h:/'.IO.d {
 say;
 }

which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter



Hi Peter,

Of course!  I am not arguing with anyone that
they are not right!

I am doing what I am doing to make things easier for
me to read in the future.  Since I am already using
a very high level language, what is one more affront
to my CPU?

:-)

-T


Peter,

I am not a full time programmer.  I am I.T. support
to small busienses.  Programming is only about 10
to 20% of what I do.  Wednesday, I get to fix an
sql server installer that things it is being given
the wrong (speaking) language.  I DO EVERYTHING !!!

The things I write MUST be maintainable.  When I go back
to them, I won't remember everything on the fly.  EVEN
THOUGH I have copous notes and HOW TOs.

If you want me to change my wicked way, come up with
something even more understandable, human readable
"on the fly".

And with the talent you have already displayed, I know
you can.  You are very, very good at this stuff.

:-)

-T


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 17:14, Peter Pentchev wrote:

On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users wrote:

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.


OK, so why does it give you an error message if you run it? :)

Not quite.

 say if 'h:/'.IO.d

...is equivalent to:

 if 'h:/'.IO.d {
 say;
 }

which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter



Hi Peter,

Of course!  I am not arguing with anyone that
they are not right!

I am doing what I am doing to make things easier for
me to read in the future.  Since I am already using
a very high level language, what is one more affront
to my CPU?

:-)

-T


Re: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Mon, May 18, 2020 at 04:53:31PM -0700, ToddAndMargo via perl6-users wrote:
> In 2020-05-18 16:11, Peter Pentchev wrote:
> > As an exercise for the reader: once the above sinks in, what exactly
> > will "say if 'h:/'.IO.d" do?
> 
> It returns the the result of the expression that
> "if" evaluated.

OK, so why does it give you an error message if you run it? :)

Not quite.

say if 'h:/'.IO.d

...is equivalent to:

if 'h:/'.IO.d {
say;
}

which would have been valid in Perl (apart from the parentheses
around the condition of the "if", Raku allows you to omit those), but
it is not valid Raku. Run it and see what it says.

Once again you thought that "if" returns a value. "If" does not return
a value, it is not a function, it is a statement. Just the same as "for"
does not return a value, and "while" does not return a value.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

In 2020-05-18 16:11, Peter Pentchev wrote:

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do?


It returns the the result of the expression that
"if" evaluated.

I do know all this.  It is easier for me to read
the other way.


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 16:01, Tom Browder wrote:

Since you don't like to listen to advice I give up.


Tom!

I listen to your advice ALL-THE-TIME.  I was
just interested in something else.  And when I did
not understand the result, your way or my way,
I abandoned the effort, especially since I did not
need the information.  It was just a curiosity.

Don't for a second think I do not value your advice!

-T


Re: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Mon, May 18, 2020 at 03:51:30PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-18 15:44, Tom Browder wrote:
> > On Mon, May 18, 2020 at 16:19 ToddAndMargo via perl6-users
> > mailto:perl6-users@perl.org>> wrote:
> > 
> > On 2020-05-18 13:28, Tom Browder wrote:
> > 
> > ...
> > 
> >  > Try:
> >  >
> >  > 'say so "test".IO.d'
> > 
> > 
> > Todd, you didn't try what I suggested. Once again, look a the line above^^
> > 
> > There is no "if" there.
> > 
> > -Tom
> > 
> 
> It was the "if" I was interested in.  "if" has to change
> a True or "useless text message" into a True or False.

No, that's not what "if" does. "If" in Raku works pretty much
the same way as "if" in Perl: it takes an expression as
an argument, checks whether the expression is true or false
(that's the part where it takes any value and does a .Bool on
it - by itself - and then looks at the result), and then, if
it was true, the "if" statement runs another part of the code.
So:

if 'h:/'.IO.d {
say 'It is a directory!';
}

...will take the string 'h:/', the .IO method will convert it to
a path, the .d method will check whether the path corresponds to
a valid directory at this moment, and then the "if" statement will
check the result of this whole thing and decide whether to run
the { say... } block. If the path is a directory, it will tell you
that it is a directory. If the expression is true, it runs the code.

The postfix "if" also works in pretty much the same way as in Perl:
it allows you to shorten this:

if 'h:/'.IO.d {
say 'It is a directory!';
}

...to this:

say 'It is a directory!' if 'h:/'.IO.d;

Now you will note that in my example I did *not* write
"say if 'h:/'.IO.d", because I did not expect the "if" to return
a value; I wrote "say 'foo' if 'h:/'.IO.d" since I expected the "if"
statement to make Raku check whether 'h:/'.IO.d returns something that
looks like truth and, if it does, to execute the "say 'foo'" part.

I'm sorry, I assumed that you were familiar with the postfix "if" form
(something if something-else). Maybe you did not recognize it as such,
sorry.

As an exercise for the reader: once the above sinks in, what exactly
will "say if 'h:/'.IO.d" do? :)

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread Tom Browder
On Mon, May 18, 2020 at 17:51 ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-18 15:44, Tom Browder wrote:
> > On Mon, May 18, 2020 at 16:19 ToddAndMargo via perl6-users
> > mailto:perl6-users@perl.org>> wrote:
> >
> > On 2020-05-18 13:28, Tom Browder wrote:
> >
> > ...
> >
> >  > Try:
> >  >
> >  > 'say so "test".IO.d'
> >
> >
> > Todd, you didn't try what I suggested. Once again, look a the line
> above^^
> >
> > There is no "if" there.
> >
> > -Tom
> >
>
> It was the "if" I was interested in.  "if" has to change
> a True or "useless text message" into a True or False.


Since you don't like to listen to advice I give up. The 'so' I was taught
by lizmat (or some other expert) a long time ago does the pretty much the
same thing  execpt it makes a valid statement, whereas I'm not sure the
other way does (hard to read your emails with all the superflous output).


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 15:44, Tom Browder wrote:
On Mon, May 18, 2020 at 16:19 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-05-18 13:28, Tom Browder wrote:

...

 > Try:
 >
 > 'say so "test".IO.d'


Todd, you didn't try what I suggested. Once again, look a the line above^^

There is no "if" there.

-Tom



It was the "if" I was interested in.  "if" has to change
a True or "useless text message" into a True or False.

Anyway, since I don't understand anything that came
back, I am going to give up.

And besides, any extra work I am giving the compiler
with my coercing a Bool into a Bool so I don't
remember which IO.someletter give back an actual
Boolean and which ones don't, is SWAMPED by my use
of a high level language.  This is not Assembly.


Re: I need help with IO.e

2020-05-18 Thread Tom Browder
On Mon, May 18, 2020 at 16:19 ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-18 13:28, Tom Browder wrote:

...

> > Try:
> >
> > 'say so "test".IO.d'


Todd, you didn't try what I suggested. Once again, look a the line above^^

There is no "if" there.

-Tom


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 15:38, Peter Pentchev wrote:

On Mon, May 18, 2020 at 03:18:26PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-18 14:35, Peter Pentchev wrote:

My point is that you put a bare "say" without telling it*what*  to say,
which does something quite specific in both Perl and Raku. That should,
at least, explain the error-like message.

G'luck,
Peter


What I was after was to see what impact I had coercing a
Bool to a Bool verses coercing a half a Bool and unless
text message to a Bool.

[snip another explanation of why you use .Bool, which I already
  said that I am not commenting on; my point is something entirely
  different]

All I was trying to say was to explain that "say if something" and
"say 'foo' if something" do different things, to answer your question
from a previous message why "say if something" told you something
about undefined values. That's all I was trying to help you with :)

G'luck,
Peter



I got it.  I was only rambling on.  I tend to do that.


Re: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Mon, May 18, 2020 at 03:18:26PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-18 14:35, Peter Pentchev wrote:
> > My point is that you put a bare "say" without telling it*what*  to say,
> > which does something quite specific in both Perl and Raku. That should,
> > at least, explain the error-like message.
> > 
> > G'luck,
> > Peter
> 
> What I was after was to see what impact I had coercing a
> Bool to a Bool verses coercing a half a Bool and unless
> text message to a Bool.
[snip another explanation of why you use .Bool, which I already
 said that I am not commenting on; my point is something entirely
 different]

All I was trying to say was to explain that "say if something" and
"say 'foo' if something" do different things, to answer your question
from a previous message why "say if something" told you something
about undefined values. That's all I was trying to help you with :)

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 14:35, Peter Pentchev wrote:

My point is that you put a bare "say" without telling it*what*  to say,
which does something quite specific in both Perl and Raku. That should,
at least, explain the error-like message.

G'luck,
Peter


What I was after was to see what impact I had coercing a
Bool to a Bool verses coercing a half a Bool and unless
text message to a Bool.

But, you know, I am using a (very) high lever language
for a reason.  I can get to the final product twice as
fast.  If I wanted to optimize the use of my CPU, I would
program in C, or if I was REALLY masochistic, I program
in Assembly.  (Done that, don't want to do it again!)

So my little coercing Bool to Bool so I do not have to
remember which IO.soemletter is or is not returning an
actual Boolean is a mute point.  I am already wasting
a ton of CPU by being in a high level language to start with.

And I don't care.  My computer is a bazillion times more powerful than 
any thing I waste on a high level language.

It hardly notices my "indiscretion"

An gee wiz, Raku is a TON more human readable than C,
which gives me a migraine if I stare at it too long.
Raku is far more maintainable.  But that is just my opinion


Re: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Mon, May 18, 2020 at 02:32:49PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-18 14:22, Peter Pentchev wrote:
> > Please note that in my example a couple of messages ago I did not write
> > "say if 'h:/'.IO.d", I wrote "say 'yes' if 'h:/'.IO.d". The difference
> > is very important and leads directly to the error-like message you got.
> 
> 
> Hi Peter,
> 
> I as interested in the .d difference, so I put that
> in instead.
> 
> But it does not matter.  I can't tell what I am looking at
> so it does not matter anyway

My point is that you put a bare "say" without telling it *what* to say,
which does something quite specific in both Perl and Raku. That should,
at least, explain the error-like message.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 14:22, Peter Pentchev wrote:

Please note that in my example a couple of messages ago I did not write
"say if 'h:/'.IO.d", I wrote "say 'yes' if 'h:/'.IO.d". The difference
is very important and leads directly to the error-like message you got.



Hi Peter,

I as interested in the .d difference, so I put that
in instead.

But it does not matter.  I can't tell what I am looking at
so it does not matter anyway

Thank you for all the wonderful help!

-T


Re: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Tue, May 19, 2020 at 12:22:55AM +0300, Peter Pentchev wrote:
> On Mon, May 18, 2020 at 12:35:47PM -0700, ToddAndMargo via perl6-users wrote:
> > On 2020-05-17 22:28, Paul Procacci wrote:
> > > Don't 'say' anything.  Just let the optimizer spit out the QAST that you
> > > are interested in looking at.
> > > The following spits out a diff after optimization:
> > > 
> > > # diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6
> > > --target=optimize -e '"test".IO.e.Bool')
> > > 
> > >  >> Huh.  Not sure what I am looking at
> > > 
> > > You aren't specific.  Is it the error message you received because you
> > > used 'say' improperly or is it the QAST?
> > > - How to use 'say' is in the documentation.
> > > - A QAST is pretty close to an AST and I'd start there on wikipedia or
> > > something.
> > 
> > I was looking for the difference between
> > 
> > 'say if "test".IO.d',  and
> 
> Please note that in my example a couple of messages ago I did not write
> "say if 'h:/'.IO.d", I wrote "say 'yes' if 'h:/'.IO.d". The difference
> is very important and leads directly to the error-like message you got.
> 
> > 'say "test".IO.d.Bool'
> > 
> > This is were 'if" has to unscramble a "True" or
> > "text message" return.
> > 
> > But, I have no idea what all that stuff is that comes
> > back anyway, so I think I will give up.
> 
> It's the internal representation of the program you told Raku to parse
> and execute; the truth is that, just like in a sci-fi story about
> a machine that is supposed to answer any question, but only comes back
> with "the question has not been asked correctly", ...

In case anybody is curious,
http://www.gutenberg.org/cache/epub/33854/pg33854.txt

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread Peter Pentchev
On Mon, May 18, 2020 at 12:35:47PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-17 22:28, Paul Procacci wrote:
> > Don't 'say' anything.  Just let the optimizer spit out the QAST that you
> > are interested in looking at.
> > The following spits out a diff after optimization:
> > 
> > # diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6
> > --target=optimize -e '"test".IO.e.Bool')
> > 
> >  >> Huh.  Not sure what I am looking at
> > 
> > You aren't specific.  Is it the error message you received because you
> > used 'say' improperly or is it the QAST?
> > - How to use 'say' is in the documentation.
> > - A QAST is pretty close to an AST and I'd start there on wikipedia or
> > something.
> 
> I was looking for the difference between
> 
> 'say if "test".IO.d',  and

Please note that in my example a couple of messages ago I did not write
"say if 'h:/'.IO.d", I wrote "say 'yes' if 'h:/'.IO.d". The difference
is very important and leads directly to the error-like message you got.

> 'say "test".IO.d.Bool'
> 
> This is were 'if" has to unscramble a "True" or
> "text message" return.
> 
> But, I have no idea what all that stuff is that comes
> back anyway, so I think I will give up.

It's the internal representation of the program you told Raku to parse
and execute; the truth is that, just like in a sci-fi story about
a machine that is supposed to answer any question, but only comes back
with "the question has not been asked correctly", and just as with using
low-level debugging tools like strace on Unix-like systems, to ask
the right question one already needs to know most of the answer.
The QAST is most useful to those who already have some idea how
a compiler generally works, how a pseudocode virtual machine works,
how a just-in-time compiler works, and how they all handle different
expressions and the relationships between different types.

G'luck,
Peter

-- 
-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-18 13:28, Tom Browder wrote:
On Mon, May 18, 2020 at 14:36 ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2020-05-17 22:28, Paul Procacci wrote:

...

'say if "test".IO.d',  and
'say "test".IO.d.Bool'


Try:

'say so "test".IO.d'



I have mo clue that this says



$ diff -u <(perl6 --target=optimize -e 'so if "test".IO.d') <(perl6 
--target=optimize -e 'so "test".IO.d.Bool')

===SORRY!=== Error while compiling -e
Undeclared routine:
if used at line 1

WARNINGS for -e:
Useless use of "so " in expression "so \"test\".IO.d.Bool" in sink 
context (line 1)

--- /dev/fd/63  2020-05-18 14:17:32.731286061 -0700
+++ /dev/fd/62  2020-05-18 14:17:32.732286043 -0700
@@ -0,0 +1,98 @@
+- QAST::CompUnit  :W :UNIT :CAN_LOWER_TOPIC
+  [pre_deserialize]
+- QAST::Stmt
+  - QAST::Stmt
+- QAST::Op(loadbytecode)
+  - QAST::VM
+[moar]
+  - QAST::SVal(ModuleLoader.moarvm)
+[jvm]
+  - QAST::SVal(ModuleLoader.class)
+[js]
+  - QAST::SVal(ModuleLoader)
+- QAST::Op(callmethod load_module)
+  - QAST::Op(gethllsym)
+- QAST::SVal(nqp)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(Perl6::ModuleLoader)
+  - QAST::Op(forceouterctx)
+- QAST::BVal(2)
+- QAST::Op(callmethod load_setting)
+  - QAST::Op(getcurhllsym)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(CORE.d)
+  [post_deserialize]
+- QAST::Stmts
+  - QAST::Op(bind)
+- QAST::Var(attribute $!do)
+  - QAST::WVal(Block)
+  - QAST::WVal(Code)
+- QAST::BVal(1)
+- QAST::Op(bindcurhllsym)
+  - QAST::SVal(GLOBAL)
+  - QAST::WVal(GLOBAL)
+  [load]
+- QAST::Op(call)
+  - QAST::BVal(2)
+  [children]
+- QAST::Block(:cuid(2))  :in_stmt_mod so \"test\".IO.d.Bool
+│ - QAST::Var(local __args__ :decl(param))
+│ - QAST::Stmts  so \"test\".IO.d.Bool
+│ - QAST::Op(call)
+│   - QAST::Block(:cuid(1) :blocktype(declaration_static)) 
:outer :in_stmt_mod :code_object :IN_DECL

+│   │ - QAST::Stmts  so \"test\".IO.d.Bool
+│   │   - QAST::Var(lexical $¢ :decl(contvar))
+│   │   - QAST::Var(lexical $! :decl(contvar))
+│   │   - QAST::Var(lexical $/ :decl(contvar))
+│   │   - QAST::Op(null)
+│   │   - QAST::Var(lexical GLOBALish :decl(static))
+│   │   - QAST::Var(lexical EXPORT :decl(static))
+│   │   - QAST::Var(lexical $?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical ::?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical $=finish :decl(static))
+│   │   - QAST::Var(lexical $=pod :decl(static))
+│   │ [value]
+│   │   -
+│   │   - QAST::Var(lexical !UNIT_MARKER :decl(static))
+│   │ - QAST::Stmts
+│   │   - QAST::Op(bind)
+│   │ - QAST::Var(local ctxsave :decl(var))
+│   │ - QAST::Var(contextual $*CTXSAVE)
+│   │   - QAST::Op(unless)
+│   │ - QAST::Op(isnull)
+│   │   - QAST::Var(local ctxsave)
+│   │ - QAST::Op(if)
+│   │   - QAST::Op(can)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::SVal(ctxsave)
+│   │   - QAST::Op(callmethod ctxsave)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::Stmts
+│   │   - QAST::WVal(Array)
+│   │   - QAST::Stmt  so \"test\".IO.d.Bool
+│   │ - QAST::Want 
+│   │   - QAST::Op(callstatic &prefix:)  
:statement_id<1> so

+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod Bool)  Bool
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod d)  d
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod IO)  IO
+│   │ - QAST::Want  test
+│   │   - QAST::WVal(Str)
+│   │   - Ss
+│   │   - QAST::SVal(test)
+│   │   - v
+│   │   - QAST::Op(p6sink)
+│   │ - QAST::Op(callstatic &prefix:)  
:statement_id<1> so

+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod Bool)  Bool
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod d)  d
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod IO)  IO
+│   │   - QAST::Want  test
+│   │ - QAST::WVal(Str)
+│   │ - Ss
+│   │ - QAST::SVal(test)
+│   │   - QAST::WVal(Nil)


Re: I need help with IO.e

2020-05-18 Thread Tom Browder
On Mon, May 18, 2020 at 14:36 ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-17 22:28, Paul Procacci wrote:

...

> 'say if "test".IO.d',  and
> 'say "test".IO.d.Bool'


Try:

'say so "test".IO.d'


Re: I need help with IO.e

2020-05-18 Thread ToddAndMargo via perl6-users

On 2020-05-17 22:28, Paul Procacci wrote:
Don't 'say' anything.  Just let the optimizer spit out the QAST that you 
are interested in looking at.

The following spits out a diff after optimization:

# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6 
--target=optimize -e '"test".IO.e.Bool')


 >> Huh.  Not sure what I am looking at

You aren't specific.  Is it the error message you received because you 
used 'say' improperly or is it the QAST?

- How to use 'say' is in the documentation.
- A QAST is pretty close to an AST and I'd start there on wikipedia or 
something.


I was looking for the difference between

'say if "test".IO.d',  and
'say "test".IO.d.Bool'

This is were 'if" has to unscramble a "True" or
"text message" return.

But, I have no idea what all that stuff is that comes
back anyway, so I think I will give up.

Thank you for all the help!

-T


Re: I need help with IO.e

2020-05-17 Thread Paul Procacci
Don't 'say' anything.  Just let the optimizer spit out the QAST that you
are interested in looking at.
The following spits out a diff after optimization:

# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6
--target=optimize -e '"test".IO.e.Bool')

>> Huh.  Not sure what I am looking at

You aren't specific.  Is it the error message you received because you used
'say' improperly or is it the QAST?
- How to use 'say' is in the documentation.
- A QAST is pretty close to an AST and I'd start there on wikipedia or
something.

On Mon, May 18, 2020 at 1:03 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-17 21:48, Paul Procacci wrote:
> > You can check this yourself by looking at the QAST nodes after the
> > static analyzer has had its fill:
> >
> > # diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6
> > --target=optimize -e '"test".IO.e.Bool')
>
> Huh.  Not sure what I am looking at
>
>
> $ diff -u <(perl6 --target=optimize -e 'say if "test".IO.d') <(perl6
> --target=optimize -e 'say "test".IO.d.Bool')
> ===SORRY!=== Error while compiling -e
> Unsupported use of bare "say"; in Raku please use .say if you meant to
> call it as a method on $_, or use an explicit invocant or argument, or
> use &say to refer to the function as a noun
> at -e:1
> --> say⏏ if "test".IO.d
> --- /dev/fd/63  2020-05-17 22:01:37.947790677 -0700
> +++ /dev/fd/62  2020-05-17 22:01:37.948790659 -0700
> @@ -0,0 +1,98 @@
> +- QAST::CompUnit  :W :UNIT :CAN_LOWER_TOPIC
> +  [pre_deserialize]
> +- QAST::Stmt
> +  - QAST::Stmt
> +- QAST::Op(loadbytecode)
> +  - QAST::VM
> +[moar]
> +  - QAST::SVal(ModuleLoader.moarvm)
> +[jvm]
> +  - QAST::SVal(ModuleLoader.class)
> +[js]
> +  - QAST::SVal(ModuleLoader)
> +- QAST::Op(callmethod load_module)
> +  - QAST::Op(gethllsym)
> +- QAST::SVal(nqp)
> +- QAST::SVal(ModuleLoader)
> +  - QAST::SVal(Perl6::ModuleLoader)
> +  - QAST::Op(forceouterctx)
> +- QAST::BVal(2)
> +- QAST::Op(callmethod load_setting)
> +  - QAST::Op(getcurhllsym)
> +- QAST::SVal(ModuleLoader)
> +  - QAST::SVal(CORE.d)
> +  [post_deserialize]
> +- QAST::Stmts
> +  - QAST::Op(bind)
> +- QAST::Var(attribute $!do)
> +  - QAST::WVal(Block)
> +  - QAST::WVal(Code)
> +- QAST::BVal(1)
> +- QAST::Op(bindcurhllsym)
> +  - QAST::SVal(GLOBAL)
> +  - QAST::WVal(GLOBAL)
> +  [load]
> +- QAST::Op(call)
> +  - QAST::BVal(2)
> +  [children]
> +- QAST::Block(:cuid(2))  :in_stmt_mod say \"test\".IO.d.Bool
> +│ - QAST::Var(local __args__ :decl(param))
> +│ - QAST::Stmts  say \"test\".IO.d.Bool
> +│ - QAST::Op(call)
> +│   - QAST::Block(:cuid(1) :blocktype(declaration_static))
> :outer :in_stmt_mod :code_object :IN_DECL
> +│   │ - QAST::Stmts  say \"test\".IO.d.Bool
> +│   │   - QAST::Var(lexical $¢ :decl(contvar))
> +│   │   - QAST::Var(lexical $! :decl(contvar))
> +│   │   - QAST::Var(lexical $/ :decl(contvar))
> +│   │   - QAST::Op(null)
> +│   │   - QAST::Var(lexical GLOBALish :decl(static))
> +│   │   - QAST::Var(lexical EXPORT :decl(static))
> +│   │   - QAST::Var(lexical $?PACKAGE :decl(static))
> +│   │   - QAST::Var(lexical ::?PACKAGE :decl(static))
> +│   │   - QAST::Var(lexical $=finish :decl(static))
> +│   │   - QAST::Var(lexical $=pod :decl(static))
> +│   │ [value]
> +│   │   -
> +│   │   - QAST::Var(lexical !UNIT_MARKER :decl(static))
> +│   │ - QAST::Stmts
> +│   │   - QAST::Op(bind)
> +│   │ - QAST::Var(local ctxsave :decl(var))
> +│   │ - QAST::Var(contextual $*CTXSAVE)
> +│   │   - QAST::Op(unless)
> +│   │ - QAST::Op(isnull)
> +│   │   - QAST::Var(local ctxsave)
> +│   │ - QAST::Op(if)
> +│   │   - QAST::Op(can)
> +│   │ - QAST::Var(local ctxsave)
> +│   │ - QAST::SVal(ctxsave)
> +│   │   - QAST::Op(callmethod ctxsave)
> +│   │ - QAST::Var(local ctxsave)
> +│   │ - QAST::Stmts
> +│   │   - QAST::WVal(Array)
> +│   │   - QAST::Stmt  say \"test\".IO.d.Bool
> +│   │ - QAST::Want 
> +│   │   - QAST::Op(callstatic &say)  :statement_id<1> say
> \"test\".IO.d.Bool
> +│   │ - QAST::Op(hllize) 
> +│   │   - QAST::Op(callmethod Bool)  Bool
> +│   │ - QAST::Op(hllize) 
> +│   │   - QAST::Op(callmethod d)  d
> +│   │ - QAST::Op(hllize) 
> +│   │   - QAST::Op(callmethod IO)  IO
> +│   │ - QAST::Want  test
> +│   │   - QAST::WVal(Str)
> +│   │   - Ss
> +│   │   - QAST::SVal(test)
> +│   │   - v
> +│   │   - QAST::Op(p6sink)
> +│   │ 

Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 21:48, Paul Procacci wrote:
You can check this yourself by looking at the QAST nodes after the 
static analyzer has had its fill:


# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6 
--target=optimize -e '"test".IO.e.Bool')


Huh.  Not sure what I am looking at


$ diff -u <(perl6 --target=optimize -e 'say if "test".IO.d') <(perl6 
--target=optimize -e 'say "test".IO.d.Bool')

===SORRY!=== Error while compiling -e
Unsupported use of bare "say"; in Raku please use .say if you meant to 
call it as a method on $_, or use an explicit invocant or argument, or 
use &say to refer to the function as a noun

at -e:1
--> say⏏ if "test".IO.d
--- /dev/fd/63  2020-05-17 22:01:37.947790677 -0700
+++ /dev/fd/62  2020-05-17 22:01:37.948790659 -0700
@@ -0,0 +1,98 @@
+- QAST::CompUnit  :W :UNIT :CAN_LOWER_TOPIC
+  [pre_deserialize]
+- QAST::Stmt
+  - QAST::Stmt
+- QAST::Op(loadbytecode)
+  - QAST::VM
+[moar]
+  - QAST::SVal(ModuleLoader.moarvm)
+[jvm]
+  - QAST::SVal(ModuleLoader.class)
+[js]
+  - QAST::SVal(ModuleLoader)
+- QAST::Op(callmethod load_module)
+  - QAST::Op(gethllsym)
+- QAST::SVal(nqp)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(Perl6::ModuleLoader)
+  - QAST::Op(forceouterctx)
+- QAST::BVal(2)
+- QAST::Op(callmethod load_setting)
+  - QAST::Op(getcurhllsym)
+- QAST::SVal(ModuleLoader)
+  - QAST::SVal(CORE.d)
+  [post_deserialize]
+- QAST::Stmts
+  - QAST::Op(bind)
+- QAST::Var(attribute $!do)
+  - QAST::WVal(Block)
+  - QAST::WVal(Code)
+- QAST::BVal(1)
+- QAST::Op(bindcurhllsym)
+  - QAST::SVal(GLOBAL)
+  - QAST::WVal(GLOBAL)
+  [load]
+- QAST::Op(call)
+  - QAST::BVal(2)
+  [children]
+- QAST::Block(:cuid(2))  :in_stmt_mod say \"test\".IO.d.Bool
+│ - QAST::Var(local __args__ :decl(param))
+│ - QAST::Stmts  say \"test\".IO.d.Bool
+│ - QAST::Op(call)
+│   - QAST::Block(:cuid(1) :blocktype(declaration_static)) 
:outer :in_stmt_mod :code_object :IN_DECL

+│   │ - QAST::Stmts  say \"test\".IO.d.Bool
+│   │   - QAST::Var(lexical $¢ :decl(contvar))
+│   │   - QAST::Var(lexical $! :decl(contvar))
+│   │   - QAST::Var(lexical $/ :decl(contvar))
+│   │   - QAST::Op(null)
+│   │   - QAST::Var(lexical GLOBALish :decl(static))
+│   │   - QAST::Var(lexical EXPORT :decl(static))
+│   │   - QAST::Var(lexical $?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical ::?PACKAGE :decl(static))
+│   │   - QAST::Var(lexical $=finish :decl(static))
+│   │   - QAST::Var(lexical $=pod :decl(static))
+│   │ [value]
+│   │   -
+│   │   - QAST::Var(lexical !UNIT_MARKER :decl(static))
+│   │ - QAST::Stmts
+│   │   - QAST::Op(bind)
+│   │ - QAST::Var(local ctxsave :decl(var))
+│   │ - QAST::Var(contextual $*CTXSAVE)
+│   │   - QAST::Op(unless)
+│   │ - QAST::Op(isnull)
+│   │   - QAST::Var(local ctxsave)
+│   │ - QAST::Op(if)
+│   │   - QAST::Op(can)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::SVal(ctxsave)
+│   │   - QAST::Op(callmethod ctxsave)
+│   │ - QAST::Var(local ctxsave)
+│   │ - QAST::Stmts
+│   │   - QAST::WVal(Array)
+│   │   - QAST::Stmt  say \"test\".IO.d.Bool
+│   │ - QAST::Want 
+│   │   - QAST::Op(callstatic &say)  :statement_id<1> say 
\"test\".IO.d.Bool

+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod Bool)  Bool
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod d)  d
+│   │ - QAST::Op(hllize) 
+│   │   - QAST::Op(callmethod IO)  IO
+│   │ - QAST::Want  test
+│   │   - QAST::WVal(Str)
+│   │   - Ss
+│   │   - QAST::SVal(test)
+│   │   - v
+│   │   - QAST::Op(p6sink)
+│   │ - QAST::Op(callstatic &say)  :statement_id<1> 
say \"test\".IO.d.Bool

+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod Bool)  Bool
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod d)  d
+│   │   - QAST::Op(hllize) 
+│   │ - QAST::Op(callmethod IO)  IO
+│   │   - QAST::Want  test
+│   │ - QAST::WVal(Str)
+│   │ - Ss
+│   │ - QAST::SVal(test)
+│   │   - QAST::WVal(Nil)


Re: I need help with IO.e

2020-05-17 Thread Paul Procacci
You can check this yourself by looking at the QAST nodes after the static
analyzer has had its fill:

# diff -u <(perl6 --target=optimize -e '"test".IO.e') <(perl6
--target=optimize -e '"test".IO.e.Bool')

On Mon, May 18, 2020 at 12:25 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-17 21:19, ToddAndMargo via perl6-users wrote:
> > On 2020-05-17 20:28, Paul Procacci wrote:
> >> So tack a .Bool at the end.
> >> You are coercing a bool to a bool by doing so and hopefully the
> >> optimizer is smart enough for people who like to be redundant.
> >>
> >> ;)
> >
> > Hi Paul,
> >
> > Especially when I can never remember when IO.someletter
> > will return a full True or False Boolean and when it
> > will return a True or a useless text message.
> >
> > The optimizer should have a lot of fun with me!  Works
> > darned well too!
> >
> > -T
>
> Speaking of optimizer, it would be interesting to see
> if my coercing a half a Bool and a useless text message
> to a True of False when analyzed takes  more of less
> optimizing than giving it a straight Boolean to start with.
>
> But now I are getting at some really deep trivia
>


-- 
__

:(){ :|:& };:


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 21:19, ToddAndMargo via perl6-users wrote:

On 2020-05-17 20:28, Paul Procacci wrote:

So tack a .Bool at the end.
You are coercing a bool to a bool by doing so and hopefully the 
optimizer is smart enough for people who like to be redundant.


;)


Hi Paul,

Especially when I can never remember when IO.someletter
will return a full True or False Boolean and when it
will return a True or a useless text message.

The optimizer should have a lot of fun with me!  Works
darned well too!

-T


Speaking of optimizer, it would be interesting to see
if my coercing a half a Bool and a useless text message
to a True of False when analyzed takes  more of less
optimizing than giving it a straight Boolean to start with.

But now I are getting at some really deep trivia


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 20:28, Paul Procacci wrote:

So tack a .Bool at the end.
You are coercing a bool to a bool by doing so and hopefully the 
optimizer is smart enough for people who like to be redundant.


;)


Hi Paul,

Especially when I can never remember when IO.someletter
will return a full True or False Boolean and when it
will return a True or a useless text message.

The optimizer should have a lot of fun with me!  Works
darned well too!

-T


Re: I need help with IO.e

2020-05-17 Thread Paul Procacci
So tack a .Bool at the end.
You are coercing a bool to a bool by doing so and hopefully the optimizer
is smart enough for people who like to be redundant.

;)

On Sun, May 17, 2020 at 6:10 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-17 14:43, ToddAndMargo via perl6-users wrote:
> > Although
> >
> > "say 'yes' if 'h:/'.IO.d"
> >
> > is obscure to me and
> >
> > "say 'h:/'.IO.d.Bool"
> >
> > is very easy for me to understand.
>
>
> Hi Peter,
>
> I think it would help if you knew how my
> mind worked.
>
> `if` to me is a Boolean function.  If this
> expressions is true, do this, if not, do
> something else.
>
> This is what happens to me when I see expressions
> like
>
>  "say 'yes' if 'h:/'.IO.d"
>
> if the expression (h:/.IO.d) is true, then
> say the result of the expression test, not the
> result from the expression.  I have to figure
> out what the results from the expression are
> and why it is passing or failing the test.
>
> Two steps in my mind.  Not that I can't figure
> things like this out, I just don't like the effort,
> when it can be avoided.  The way I look at it, the
> time it takes me to write five extra letters (.Bool)
> will save me ten times that amount of time trying to
> figure out what I did 5 days or 5 years from now.
> Dr. Demming (Quality circles, Kaisen, etc.) makes
> a very strong point of this
>
> And `if` can actually be very helpful at times:
> if  $x ~~ s/ "abc" /def/ {...;}
> will tell you if the regex actually found "abc".
> This I adore because I know is a test.  Not
> in the least bit obscure.
>
> .d is suppose to return a Boolen, but does not.
> Some functions will convert the junk for you on
> the fly.  Raku is very friendly this way.  Five extra
> letters and I do not have to wonder who does what
> to whom.
>
> Yes, I am a bit weird.
>
> Thank you for all the wonderful explanations!  Very
> much appreciated.
>
> -T
>


-- 
__

:(){ :|:& };:


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 14:43, ToddAndMargo via perl6-users wrote:

Although

    "say 'yes' if 'h:/'.IO.d"

is obscure to me and

    "say 'h:/'.IO.d.Bool"

is very easy for me to understand.



Hi Peter,

I think it would help if you knew how my
mind worked.

`if` to me is a Boolean function.  If this
expressions is true, do this, if not, do
something else.

This is what happens to me when I see expressions
like

"say 'yes' if 'h:/'.IO.d"

if the expression (h:/.IO.d) is true, then
say the result of the expression test, not the
result from the expression.  I have to figure
out what the results from the expression are
and why it is passing or failing the test.

Two steps in my mind.  Not that I can't figure
things like this out, I just don't like the effort,
when it can be avoided.  The way I look at it, the
time it takes me to write five extra letters (.Bool)
will save me ten times that amount of time trying to
figure out what I did 5 days or 5 years from now.
Dr. Demming (Quality circles, Kaisen, etc.) makes
a very strong point of this

And `if` can actually be very helpful at times:
   if  $x ~~ s/ "abc" /def/ {...;}
will tell you if the regex actually found "abc".
This I adore because I know is a test.  Not
in the least bit obscure.

.d is suppose to return a Boolen, but does not.
Some functions will convert the junk for you on
the fly.  Raku is very friendly this way.  Five extra
letters and I do not have to wonder who does what
to whom.

Yes, I am a bit weird.

Thank you for all the wonderful explanations!  Very
much appreciated.

-T


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 13:04, Peter Pentchev wrote:

On Sun, May 17, 2020 at 12:12:51PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 03:36, Peter Pentchev wrote:

On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

 if not  "%Options".IO.d.Bool  {
say "Creating %Options";
mkdir( %Options", 0o777 );
 }

I definitely do not tack .Bool onto the end
of my `if` statements.


Uh. That's exactly what you're doing. You do *not* need the .Bool
there at the end. The "not" makes Raku convert whatever is there
to a boolean, so the .Bool is implicit. And if you were to check
the other way, if you had "if $foo.IO.d { ... }", then the "if"
makes Raku convert whatever is there to a boolean, so the .Bool is
implicit. You do not need to put the .Bool in an "if" or a "while"
statement.

G'luck,
Peter



Hi Peter,

Brad asked me the same thing on another thread.  This is what I
told him:

Hi Brad,

I do this because it keeps me out of trouble.

I want back a yes or no answer, not True or Fail
(X::IO::DoesNotExist).

And I never remember which IO. will return
a True or Fail or which functions (`if` does) will
convert X::IO::DoesNotExist to a False for me.


OK, so I promise to the group that this is my last message on this
particular topic :)

Todd, you won't have to remember anything if you *only* use .IO.d and
.IO.e and all the rest the way the rest of the world uses them: *only*
in conditional statements. Your examples could have been written as:

 raku -e "say 'yes' if 'h:/'.IO.d"

...and you would not have to remember anything except that .IO.d, .e,
.f, and the rest of these predicates only need to be used in
conditionals. This covers 'if', 'while', and it also covers stuff like
"my $final-decision = $path.IO.d and $path.IO.w", since this is also
using the predicates in a sort of a conditional statement. Basically,
in any *real-world* situation where you'd want to use them, you don't
need the explicit conversion to boolean.

Hope that helps.

G'luck,
Peter



Hi Peter,

Very true.

Although

   "say 'yes' if 'h:/'.IO.d"

is obscure to me and

   "say 'h:/'.IO.d.Bool"

is very easy for me to understand.

And since I am the one who is going to have to
maintain this code in perpetuity, maintainability
comes before everything else.  EVEN IF I have to
tell Raku to do something explicitly that it will
do for me on the fly.  It is all about me being
able to go into the code 5 days or 5 years
from now and being able to figure out what I did.

I had to convert a Perl 5 sub over and oh my goodness
the hoops I had to jump thought in Perl 5 that and
so very simplified in Raku.

Perl 5 does have the bad reputation of being a write
only language. (It is, only if you let it be.)

I likes Perl 5.  I ADORE Perl 6

-T

p.s. you are a wonderful teacher.  Do you have a
teaching background?


Re: I need help with IO.e

2020-05-17 Thread Peter Pentchev
On Sun, May 17, 2020 at 12:12:51PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-17 03:36, Peter Pentchev wrote:
> > On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-05-17 02:30, Peter Pentchev wrote:
> > > > You said that you would tack Bool at the end in "if" statements, too.
> > > 
> > > Hi Peter,
> > > 
> > > No wonder.  I do not remember saying that, but I could
> > > have.  My `if` statements look like:
> > > 
> > > if not  "%Options".IO.d.Bool  {
> > >say "Creating %Options";
> > >mkdir( %Options", 0o777 );
> > > }
> > > 
> > > I definitely do not tack .Bool onto the end
> > > of my `if` statements.
> > 
> > Uh. That's exactly what you're doing. You do *not* need the .Bool
> > there at the end. The "not" makes Raku convert whatever is there
> > to a boolean, so the .Bool is implicit. And if you were to check
> > the other way, if you had "if $foo.IO.d { ... }", then the "if"
> > makes Raku convert whatever is there to a boolean, so the .Bool is
> > implicit. You do not need to put the .Bool in an "if" or a "while"
> > statement.
> > 
> > G'luck,
> > Peter
> > 
> 
> Hi Peter,
> 
> Brad asked me the same thing on another thread.  This is what I
> told him:
> 
> Hi Brad,
> 
> I do this because it keeps me out of trouble.
> 
> I want back a yes or no answer, not True or Fail
> (X::IO::DoesNotExist).
> 
> And I never remember which IO. will return
> a True or Fail or which functions (`if` does) will
> convert X::IO::DoesNotExist to a False for me.

OK, so I promise to the group that this is my last message on this
particular topic :)

Todd, you won't have to remember anything if you *only* use .IO.d and
.IO.e and all the rest the way the rest of the world uses them: *only*
in conditional statements. Your examples could have been written as:

raku -e "say 'yes' if 'h:/'.IO.d"

...and you would not have to remember anything except that .IO.d, .e,
.f, and the rest of these predicates only need to be used in
conditionals. This covers 'if', 'while', and it also covers stuff like
"my $final-decision = $path.IO.d and $path.IO.w", since this is also
using the predicates in a sort of a conditional statement. Basically,
in any *real-world* situation where you'd want to use them, you don't
need the explicit conversion to boolean.

Hope that helps.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 03:50, Elizabeth Mattijsen wrote:

[11:50:21]you don.t need the .Bool, .e already returns a Bool
[11:53:07]  sometimes IO.someletter returns True of Fail, not 
False.  Tacking .Bool on the end, means I don't have to remember which ones
[11:57:23]  True or Fail.  Typo
[11:58:21]A Failure is always false
[12:03:02]  A Fail is a lot more than that.  here is an example:  >raku -e 
"say Q[z:\].IO.d;"Failed to find 'Z:\' while trying to do '.d'  in block  at -e 
line 1
[12:04:16]  I use .bool at the end because I only want back a yes 
or no answer.  And I certainly don't want it to crash.  Always using .Bool keeps me 
out of trouble
[12:19:21]say "directory foo exists" if "foo".IO.d
[12:19:49]you don't have to worry about Failure then, which is 
the point of Failure to begin with
[12:23:33]  That is `if` converting the `X::IO::DoesNotExist` 
clutter into False for me.  I never know when that will happen and when it won't, so 
tacking .Bool at the end keeps me out of trouble.  I am not a purest here.  I do not 
mind seeing .Bool at the end.   It also tells me I will be seeing a Boolean.
[12:28:42]  bye bye for now. Thank you all for the tips!


Yup,  That is it.  Keep me from having to pull my hair out.


Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 03:36, Peter Pentchev wrote:

On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

if not  "%Options".IO.d.Bool  {
   say "Creating %Options";
   mkdir( %Options", 0o777 );
}

I definitely do not tack .Bool onto the end
of my `if` statements.


Uh. That's exactly what you're doing. You do *not* need the .Bool
there at the end. The "not" makes Raku convert whatever is there
to a boolean, so the .Bool is implicit. And if you were to check
the other way, if you had "if $foo.IO.d { ... }", then the "if"
makes Raku convert whatever is there to a boolean, so the .Bool is
implicit. You do not need to put the .Bool in an "if" or a "while"
statement.

G'luck,
Peter



Hi Peter,

Brad asked me the same thing on another thread.  This is what I
told him:

Hi Brad,

I do this because it keeps me out of trouble.

I want back a yes or no answer, not True or Fail
(X::IO::DoesNotExist).

And I never remember which IO. will return
a True or Fail or which functions (`if` does) will
convert X::IO::DoesNotExist to a False for me.

Plus it makes it more readable for me.
   [something].IO..Bool
tells me instantly I will be getting back a yes
or no answer.

So if you want to be a purist, you can experiment with
which IO. are going to give you a yes
or no answer or which functions will convert X::IO::DoesNotExist for 
you.  OR you can just tack .Bool

at the end and forgo the hair pulling.

Also the cryptograms in the documentation are not
correct.  For instance:

https://docs.raku.org/routine/d

method d(--> Bool:D)

Says it return a "Bool" not a "True" or "X::IO::DoesNotExist".
The modification to Bool is stated at the bottom of the page.

So, basically, it is to keeps me out of trouble.  And if
I am going to get `X::IO::DoesNotExist` back instead of
a Boolean, .Bool automatically converts it for me and
with no hair pulling.

So, basically, my LONG WINDED answer is that I do it for me.

-T


Re: I need help with IO.e

2020-05-17 Thread Elizabeth Mattijsen
[11:50:21]  you don.t need the .Bool, .e already returns a Bool
[11:53:07]sometimes IO.someletter returns True of Fail, 
not False.  Tacking .Bool on the end, means I don't have to remember which ones
[11:57:23]True or Fail.  Typo
[11:58:21]  A Failure is always false
[12:03:02]A Fail is a lot more than that.  here is an 
example:  >raku -e "say Q[z:\].IO.d;"Failed to find 'Z:\' while trying to do 
'.d'  in block  at -e line 1
[12:04:16]I use .bool at the end because I only want back 
a yes or no answer.  And I certainly don't want it to crash.  Always using 
.Bool keeps me out of trouble
[12:19:21]  say "directory foo exists" if "foo".IO.d
[12:19:49]  you don't have to worry about Failure then, which is 
the point of Failure to begin with
[12:23:33]That is `if` converting the 
`X::IO::DoesNotExist` clutter into False for me.  I never know when that will 
happen and when it won't, so tacking .Bool at the end keeps me out of trouble.  
I am not a purest here.  I do not mind seeing .Bool at the end.   It also tells 
me I will be seeing a Boolean.
[12:28:42]bye bye for now. Thank you all for the tips!

> On 17 May 2020, at 12:36, Peter Pentchev  wrote:
> 
> On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:
>> On 2020-05-17 02:30, Peter Pentchev wrote:
>>> You said that you would tack Bool at the end in "if" statements, too.
>> 
>> Hi Peter,
>> 
>> No wonder.  I do not remember saying that, but I could
>> have.  My `if` statements look like:
>> 
>>   if not  "%Options".IO.d.Bool  {
>>  say "Creating %Options";
>>  mkdir( %Options", 0o777 );
>>   }
>> 
>> I definitely do not tack .Bool onto the end
>> of my `if` statements.
> 
> Uh. That's exactly what you're doing. You do *not* need the .Bool
> there at the end. The "not" makes Raku convert whatever is there
> to a boolean, so the .Bool is implicit. And if you were to check
> the other way, if you had "if $foo.IO.d { ... }", then the "if"
> makes Raku convert whatever is there to a boolean, so the .Bool is
> implicit. You do not need to put the .Bool in an "if" or a "while"
> statement.
> 
> G'luck,
> Peter
> 
> -- 
> Peter Pentchev  r...@ringlet.net r...@debian.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


Re: I need help with IO.e

2020-05-17 Thread Peter Pentchev
On Sun, May 17, 2020 at 03:01:34AM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-17 02:30, Peter Pentchev wrote:
> > You said that you would tack Bool at the end in "if" statements, too.
> 
> Hi Peter,
> 
> No wonder.  I do not remember saying that, but I could
> have.  My `if` statements look like:
> 
>if not  "%Options".IO.d.Bool  {
>   say "Creating %Options";
>   mkdir( %Options", 0o777 );
>}
> 
> I definitely do not tack .Bool onto the end
> of my `if` statements.

Uh. That's exactly what you're doing. You do *not* need the .Bool
there at the end. The "not" makes Raku convert whatever is there
to a boolean, so the .Bool is implicit. And if you were to check
the other way, if you had "if $foo.IO.d { ... }", then the "if"
makes Raku convert whatever is there to a boolean, so the .Bool is
implicit. You do not need to put the .Bool in an "if" or a "while"
statement.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 02:30, Peter Pentchev wrote:

You said that you would tack Bool at the end in "if" statements, too.


Hi Peter,

No wonder.  I do not remember saying that, but I could
have.  My `if` statements look like:

   if not  "%Options".IO.d.Bool  {
  say "Creating %Options";
  mkdir( %Options", 0o777 );
   }

I definitely do not tack .Bool onto the end
of my `if` statements.

Thank you for your patience!

-T


Re: I need help with IO.e

2020-05-17 Thread Peter Pentchev
On Sun, May 17, 2020 at 02:18:30AM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-17 01:23, Peter Pentchev wrote:
> > On Sat, May 16, 2020 at 06:57:53PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-05-16 17:44, Peter Pentchev wrote:
> > > > On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users 
> > > > wrote:
> > > > > On 2020-05-16 06:38, Peter Pentchev wrote:
> > > > > > > $ raku *-e* "your one-liner script here"
> > > > > > And also you might want to put some quotes around the paths to let 
> > > > > > Raku
> > > > > > know that those are strings and not some identifiers or something.
> > > > > > 
> > > > > > G'luck,
> > > > > > Peter
> > > > > > 
> > > > > 
> > > > > Hi Peter,
> > > > > 
> > > > > This is what goofed me up:
> > > > > 
> > > > > $ alias p5
> > > > > alias p5='perl -E'
> > > > > 
> > > > > $ alias p6
> > > > > alias p6='perl6 -e'
> > > > > 
> > > > > I have no such feature on the Windows side and had
> > > > > forgot about it.
> > > > > 
> > > > > Also, if you tack a .Bool on the end of IO.d, you
> > > > > get back True or False, instead of the useless True
> > > > > or Crash.  I updates my perl6.IO.txt keeper file.
> > > > > 
> > > > > And IO.e also works for directories
> > > > 
> > > > What you're doing with "tacking .Bool at the end" is usually not
> > > > necessary to do explicitly, because most people do not "say" the result
> > > > of .d or .e, but use it in an if, for, while or some such conditional
> > > > statement, in which case Raku automatically converts the expression to
> > > > a boolean, i.e. tacks a .Bool at the end.
> > > > 
> > > > The reason .d and .e return a failure otherwise is that in some cases
> > > > they may be used not in a conditional statement, but as a kind of
> > > > assertion - "I really, really think that at this point this variable
> > > > should contain a valid path to an existing directory, but if something
> > > > went wrong in my program and the variable does not contain that, I do
> > > > not want the program to go on, it would be useless, I *want* it to raise
> > > > an exception when the value is used". At least that's what I think;
> > > > I *know* that the people who rewrote .IO in v6.d are on this list, so
> > > > please correct me if I'm wrong :)
> > > > 
> > > > But the most common use of .d, .e, .f and similar, the most common by
> > > > a very large margin, is in conditionals, where Raku does the conversion
> > > > to a boolean value automatically.
> > > > 
> > > > G'luck,
> > > > Peter
> > > > 
> > > 
> > > Hi Peter,
> > > 
> > > My big issues is that  want to check to see if something
> > > is there, then take appropriate measures based on what
> > > I am doing.  Crashing is not what I want.  If I should
> > > exit based on what I find, I want the control over it.
> > 
> > So use .d in a boolean context (if, while, etc).
> > 
> > > In my "if" statements, I will use Bool anyway as it
> > > will force the issue. And will alert me that there
> > > is something else going on that I should be aware of
> > > (fail).
> > 
> > That's *exactly* the opposite of what I thought I explained, but
> > you do you, I guess.
> > 
> > > Now I have to look up f.
> > > 
> > > Found it.  If you use the Bool, it returns a False
> > > for directories.   Cool.
> > 
> > It is documented to return true for files, so yes, it would return false
> > for directories.
> > 
> > > Thank you for the detailed explanation.  Very useful
> > > and helpful!
> > > 
> > > 
> > > Just out of curiosity
> > > 
> > >   https://docs.raku.org/routine/d
> > >   (IO::Path) method d
> > >   Defined as:
> > > 
> > >   method d(--> Bool:D)
> > > 
> > >   Returns True if the invocant is a path that
> > >   exists and is a directory. The method will
> > >   fail with X::IO::DoesNotExist if the path points to
> > >   a non-existent filesystem entity.
> > > 
> > > Where in the definition
> > >  method d(--> Bool:D)
> > > does it state True or Fail?  It states "Bool".  Is
> > > something missing?
> > 
> > The definition does not list all the exceptions that a method or
> > function can throw, and for good reason - people have learned their
> > lessons from the Java world, where this, while it did have some very
> > limited use, very quickly drove programmers to just say "... raises
> > Exception" on everything, making it essentially useless.
> > 
> > OK, in more words for people who may not have any Java programming
> > experience: they tried to make programmers list any exceptions that may
> > be raised from their methods, with the expectation that programmers
> > would check the documentation for any exceptions raised by the functions
> > and methods that they call, decide which ones they want to handle and
> > which ones they want to propagate upwards, and then list the ones that
> > they propatage and the ones that they raise themselves. However, in some
> > cases, like when using several library functions from 

Re: I need help with IO.e

2020-05-17 Thread ToddAndMargo via perl6-users

On 2020-05-17 01:23, Peter Pentchev wrote:

On Sat, May 16, 2020 at 06:57:53PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 17:44, Peter Pentchev wrote:

On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories


What you're doing with "tacking .Bool at the end" is usually not
necessary to do explicitly, because most people do not "say" the result
of .d or .e, but use it in an if, for, while or some such conditional
statement, in which case Raku automatically converts the expression to
a boolean, i.e. tacks a .Bool at the end.

The reason .d and .e return a failure otherwise is that in some cases
they may be used not in a conditional statement, but as a kind of
assertion - "I really, really think that at this point this variable
should contain a valid path to an existing directory, but if something
went wrong in my program and the variable does not contain that, I do
not want the program to go on, it would be useless, I *want* it to raise
an exception when the value is used". At least that's what I think;
I *know* that the people who rewrote .IO in v6.d are on this list, so
please correct me if I'm wrong :)

But the most common use of .d, .e, .f and similar, the most common by
a very large margin, is in conditionals, where Raku does the conversion
to a boolean value automatically.

G'luck,
Peter



Hi Peter,

My big issues is that  want to check to see if something
is there, then take appropriate measures based on what
I am doing.  Crashing is not what I want.  If I should
exit based on what I find, I want the control over it.


So use .d in a boolean context (if, while, etc).


In my "if" statements, I will use Bool anyway as it
will force the issue. And will alert me that there
is something else going on that I should be aware of
(fail).


That's *exactly* the opposite of what I thought I explained, but
you do you, I guess.


Now I have to look up f.

Found it.  If you use the Bool, it returns a False
for directories.   Cool.


It is documented to return true for files, so yes, it would return false
for directories.


Thank you for the detailed explanation.  Very useful
and helpful!


Just out of curiosity

  https://docs.raku.org/routine/d
  (IO::Path) method d
  Defined as:

  method d(--> Bool:D)

  Returns True if the invocant is a path that
  exists and is a directory. The method will
  fail with X::IO::DoesNotExist if the path points to
  a non-existent filesystem entity.

Where in the definition
 method d(--> Bool:D)
does it state True or Fail?  It states "Bool".  Is
something missing?


The definition does not list all the exceptions that a method or
function can throw, and for good reason - people have learned their
lessons from the Java world, where this, while it did have some very
limited use, very quickly drove programmers to just say "... raises
Exception" on everything, making it essentially useless.

OK, in more words for people who may not have any Java programming
experience: they tried to make programmers list any exceptions that may
be raised from their methods, with the expectation that programmers
would check the documentation for any exceptions raised by the functions
and methods that they call, decide which ones they want to handle and
which ones they want to propagate upwards, and then list the ones that
they propatage and the ones that they raise themselves. However, in some
cases, like when using several library functions from several
third-party libraries, it turned out that the programmer said "oh come
on, I can't keep up with all the changes they make to their libraries,
they keep adding more and more exceptions; nah, I'll just say that my
method can throw *any* kind of exception under the Sun and be done with
it!".

Now Rust and Go are trying almost the same thing, but in a better way,
although I've seen the "propagate it, I don't care what it is!"
mentality  in both Rust ("just do .unwrap(), who cares") and Go ("is the
returned value an error? if so, return/propagate it, I don't care!")
programs (not all of them, of course).

I think that proper documentation is a better way than forcing
declarations of the errors returned, and that's what Raku does.
It does not list the exception in the method, it talks about it in
the text description.  Of course, if the Raku development team has more
insights in why they cho

Re: I need help with IO.e

2020-05-17 Thread Peter Pentchev
On Sat, May 16, 2020 at 06:57:53PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-16 17:44, Peter Pentchev wrote:
> > On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-05-16 06:38, Peter Pentchev wrote:
> > > > > $ raku *-e* "your one-liner script here"
> > > > And also you might want to put some quotes around the paths to let Raku
> > > > know that those are strings and not some identifiers or something.
> > > > 
> > > > G'luck,
> > > > Peter
> > > > 
> > > 
> > > Hi Peter,
> > > 
> > > This is what goofed me up:
> > > 
> > > $ alias p5
> > > alias p5='perl -E'
> > > 
> > > $ alias p6
> > > alias p6='perl6 -e'
> > > 
> > > I have no such feature on the Windows side and had
> > > forgot about it.
> > > 
> > > Also, if you tack a .Bool on the end of IO.d, you
> > > get back True or False, instead of the useless True
> > > or Crash.  I updates my perl6.IO.txt keeper file.
> > > 
> > > And IO.e also works for directories
> > 
> > What you're doing with "tacking .Bool at the end" is usually not
> > necessary to do explicitly, because most people do not "say" the result
> > of .d or .e, but use it in an if, for, while or some such conditional
> > statement, in which case Raku automatically converts the expression to
> > a boolean, i.e. tacks a .Bool at the end.
> > 
> > The reason .d and .e return a failure otherwise is that in some cases
> > they may be used not in a conditional statement, but as a kind of
> > assertion - "I really, really think that at this point this variable
> > should contain a valid path to an existing directory, but if something
> > went wrong in my program and the variable does not contain that, I do
> > not want the program to go on, it would be useless, I *want* it to raise
> > an exception when the value is used". At least that's what I think;
> > I *know* that the people who rewrote .IO in v6.d are on this list, so
> > please correct me if I'm wrong :)
> > 
> > But the most common use of .d, .e, .f and similar, the most common by
> > a very large margin, is in conditionals, where Raku does the conversion
> > to a boolean value automatically.
> > 
> > G'luck,
> > Peter
> > 
> 
> Hi Peter,
> 
> My big issues is that  want to check to see if something
> is there, then take appropriate measures based on what
> I am doing.  Crashing is not what I want.  If I should
> exit based on what I find, I want the control over it.

So use .d in a boolean context (if, while, etc).

> In my "if" statements, I will use Bool anyway as it
> will force the issue. And will alert me that there
> is something else going on that I should be aware of
> (fail).

That's *exactly* the opposite of what I thought I explained, but
you do you, I guess.

> Now I have to look up f.
> 
> Found it.  If you use the Bool, it returns a False
> for directories.   Cool.

It is documented to return true for files, so yes, it would return false
for directories.

> Thank you for the detailed explanation.  Very useful
> and helpful!
> 
> 
> Just out of curiosity
> 
>  https://docs.raku.org/routine/d
>  (IO::Path) method d
>  Defined as:
> 
>  method d(--> Bool:D)
> 
>  Returns True if the invocant is a path that
>  exists and is a directory. The method will
>  fail with X::IO::DoesNotExist if the path points to
>  a non-existent filesystem entity.
> 
> Where in the definition
> method d(--> Bool:D)
> does it state True or Fail?  It states "Bool".  Is
> something missing?

The definition does not list all the exceptions that a method or
function can throw, and for good reason - people have learned their
lessons from the Java world, where this, while it did have some very
limited use, very quickly drove programmers to just say "... raises
Exception" on everything, making it essentially useless.

OK, in more words for people who may not have any Java programming
experience: they tried to make programmers list any exceptions that may
be raised from their methods, with the expectation that programmers
would check the documentation for any exceptions raised by the functions
and methods that they call, decide which ones they want to handle and
which ones they want to propagate upwards, and then list the ones that
they propatage and the ones that they raise themselves. However, in some
cases, like when using several library functions from several
third-party libraries, it turned out that the programmer said "oh come
on, I can't keep up with all the changes they make to their libraries,
they keep adding more and more exceptions; nah, I'll just say that my
method can throw *any* kind of exception under the Sun and be done with
it!".

Now Rust and Go are trying almost the same thing, but in a better way,
although I've seen the "propagate it, I don't care what it is!"
mentality  in both Rust ("just do .unwrap(), who cares") and Go ("is the
returned value an error? if so, return/propagate it, I don't care!")
programs (not all of them, of course).

I 

Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 17:44, Peter Pentchev wrote:

On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users wrote:

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories


What you're doing with "tacking .Bool at the end" is usually not
necessary to do explicitly, because most people do not "say" the result
of .d or .e, but use it in an if, for, while or some such conditional
statement, in which case Raku automatically converts the expression to
a boolean, i.e. tacks a .Bool at the end.

The reason .d and .e return a failure otherwise is that in some cases
they may be used not in a conditional statement, but as a kind of
assertion - "I really, really think that at this point this variable
should contain a valid path to an existing directory, but if something
went wrong in my program and the variable does not contain that, I do
not want the program to go on, it would be useless, I *want* it to raise
an exception when the value is used". At least that's what I think;
I *know* that the people who rewrote .IO in v6.d are on this list, so
please correct me if I'm wrong :)

But the most common use of .d, .e, .f and similar, the most common by
a very large margin, is in conditionals, where Raku does the conversion
to a boolean value automatically.

G'luck,
Peter



Hi Peter,

My big issues is that  want to check to see if something
is there, then take appropriate measures based on what
I am doing.  Crashing is not what I want.  If I should
exit based on what I find, I want the control over it.

In my "if" statements, I will use Bool anyway as it
will force the issue. And will alert me that there
is something else going on that I should be aware of
(fail).

Now I have to look up f.

Found it.  If you use the Bool, it returns a False
for directories.   Cool.

Thank you for the detailed explanation.  Very useful
and helpful!


Just out of curiosity

 https://docs.raku.org/routine/d
 (IO::Path) method d
 Defined as:

 method d(--> Bool:D)

 Returns True if the invocant is a path that
 exists and is a directory. The method will
 fail with X::IO::DoesNotExist if the path points to
 a non-existent filesystem entity.

Where in the definition
method d(--> Bool:D)
does it state True or Fail?  It states "Bool".  Is
something missing?

-T


Re: I need help with IO.e

2020-05-16 Thread Peter Pentchev
On Sat, May 16, 2020 at 03:19:05PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-16 06:38, Peter Pentchev wrote:
> > > $ raku *-e* "your one-liner script here"
> > And also you might want to put some quotes around the paths to let Raku
> > know that those are strings and not some identifiers or something.
> > 
> > G'luck,
> > Peter
> > 
> 
> Hi Peter,
> 
> This is what goofed me up:
> 
> $ alias p5
> alias p5='perl -E'
> 
> $ alias p6
> alias p6='perl6 -e'
> 
> I have no such feature on the Windows side and had
> forgot about it.
> 
> Also, if you tack a .Bool on the end of IO.d, you
> get back True or False, instead of the useless True
> or Crash.  I updates my perl6.IO.txt keeper file.
> 
> And IO.e also works for directories

What you're doing with "tacking .Bool at the end" is usually not
necessary to do explicitly, because most people do not "say" the result
of .d or .e, but use it in an if, for, while or some such conditional
statement, in which case Raku automatically converts the expression to
a boolean, i.e. tacks a .Bool at the end.

The reason .d and .e return a failure otherwise is that in some cases
they may be used not in a conditional statement, but as a kind of
assertion - "I really, really think that at this point this variable
should contain a valid path to an existing directory, but if something
went wrong in my program and the variable does not contain that, I do
not want the program to go on, it would be useless, I *want* it to raise
an exception when the value is used". At least that's what I think;
I *know* that the people who rewrote .IO in v6.d are on this list, so
please correct me if I'm wrong :)

But the most common use of .d, .e, .f and similar, the most common by
a very large margin, is in conditionals, where Raku does the conversion
to a boolean value automatically.

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 06:38, Peter Pentchev wrote:

$ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter



Hi Peter,

This is what goofed me up:

$ alias p5
alias p5='perl -E'

$ alias p6
alias p6='perl6 -e'

I have no such feature on the Windows side and had
forgot about it.

Also, if you tack a .Bool on the end of IO.d, you
get back True or False, instead of the useless True
or Crash.  I updates my perl6.IO.txt keeper file.

And IO.e also works for directories

-T


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 05:34, Kevin Pye wrote:

The documentation for .d states:

Returns |True| if the invocant is a path that exists and is a directory. 
The method will |fail|  with 
|X::IO::DoesNotExist| if the path points to a non-existent filesystem 
entity.


(and by implication False if the file exists and is not a directory). In 
other words it is behaving exactly as specified.


If you want to allow for the possibility that the file does not exist at 
all, then you either need to catch the exception, or check for file 
existence first.


Something like
'p7lib'.IO ~~ :e & :d
might work, although I haven't tested it.

Kevin.



Hi Keven,

I had forgotten the -e in my Windows script
as I have it build in to my alias of P6 in Linux.
It was a real egg on the face moment.

From my point of view, IO.d giving True or crash
makes it pretty worthless.  But there are
two workaround:

IO.e also works on directories

And if you tack a .Bool on the end of IO.d it
gives you back a True or False

My notes from my perl6.IO.txt keeper:


Exists (directory):

   Warning: if you don't tack the Bool at the end, IO.d will return
True or Crash

   Note: IO.e also works on directories and is safer to use.

   DIRPATH.IO.d.Bool;
   if not $WorkingDir.IO.d.Bool { mkdir $WorkingDir, 0o766; }
   Note: do not use {} around the variable

   $ p6 'say "zef.git".IO.d.Bool;'
   True

   >raku -e "say 'h:/NotMyDocsBackup'.IO.d.Bool"
   False

   Workaround: send your command to a batch file and run the batch file


Exists (file):
   FILEPATH.IO.e
   if  $NewFileName.IO.e { $NewFileSize = $NewFileName.IO.s; } else 
{ return 4; }


   Note: IO.e.Bool misses hidden files
 https://github.com/rakudo/rakudo/issues/3594

 IO.e also works on directories



-T


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

> Le sam. 16 mai 2020 à 12:16, ToddAndMargo via perl6-users
> mailto:perl6-users@perl.org>> a écrit :
>
> On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:
>  > Hi All,.
>  >
>  > Windows 7, sp1, x64
>  >
>  >  >raku -v
>  > This is Rakudo version 2020.01 built on MoarVM version
>  > 2020.01.1 implementing Perl 6.d.
>  >
>  >
>  > I am trying to get perl to tell me if a drive letter exists
>  >
>  > This is from Git's df command:
>  >
>  >  >df -kPT H:\
>  > Filesystem Type 1024-blocks  Used Available Capacity 
Mounted on

>  > H: ntfs   38908  9964 28944  26% /h
>  >
>  > So, H:\ is there
>  >
>  >  >raku "say H:\.IO.e"
>  > Could not open say H:\.IO.e. Failed to stat file: no such file or
> directory
>  >
>  > And in case I need \\
>  >
>  >  >raku "say H:\\.IO.e"
>  > Could not open say H:\\.IO.e. Failed to stat file: no such file or
>  > directory
>  >
>  > And in case I need a forward slashL:
>  >  >raku "say H:/.IO.e"
>  > Could not open say H:/.IO.e. Failed to stat file: no such file or
> directory
>  >
>  > What am I doing wrong, this time?
>  >
>  > -T
>  >
>
>
> As far as I can tell IO.e and IO.d is completely trashed
> in Windows:
>
> K:\Windows\NtUtil>dir H:
>Volume in drive H is BACKUP
>Volume Serial Number is 00D0-CAD4
>
>Directory of H:\
>
> 05/15/2020  22:21 0 IAmBackup
> 05/15/2020  22:43  MyDocsBackup
>  1 File(s)  0 bytes
>  1 Dir(s)  29,638,656 bytes free
>
>
>
> K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
> Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such
> file or di
> rectory
>
> K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
> Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
> Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
> Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
>
> And that goes for IO.d too:
>
> K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
> Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no
> such
> file or
>directory
>
> K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
> Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: 
no such

> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
> Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: 
no such

> file or directory
>
> K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
> Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no
> such
> file or  directory
>
> This gets a TRIPLE:  :'(  :'(  :'(
>
>
>
> And it only works slightly better under Fedora:
>
> $ p6 'say "GetOptLongTest.pl6".IO.e'
> True
>
> $ p6 'say "GetOptLongTest.pl7".IO.e'
> False
>
> $ p6 'say "p6lib".IO.d'
> True
>
> $ p6 'say "p7lib".IO.d'
> Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
> in block  at -e line 1
>
> Notice that it crashed instead of returning a False.
>
> This gets a single :'(
>
>  AAHH 


> On 2020-05-16 04:29, Laurent Rosenfeld via perl6-users wrote:

Hi,

it should be:

$ raku *-e* "your one-liner script here"

Best regards,
Laurent.



Hi Laurent,

Excuse me a minute whilst I wipe some egg off my face.

mumble, mumble, mumble

Now it works


K:\Windows\NtUtil>raku -e "say 'h:/IAmBackup'.IO.e"
True

K:\Windows\NtUtil>raku -e "say 'h:/IAmNotBackup'.IO.e"
False

K:\Windows\NtUtil>raku -e "say 'h:\IAmBackup'.IO.e"
True

K:\Windows\NtUtil>raku -e "say 'h:\IAmNotBackup'.IO.e"
False


And `.d` is working better too:

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.d"
True

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.d"
Failed to find 'H:\NotMyDocsBackup' while trying to do '.d'
  in block  at -e line 1

But crashing instead of giving a False makes .d worthless.

Oh but .e works on directyories too:

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.e"
False

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.e"
True

so a workaround

And .d will work if you tack a Bool at the end:

K:\Windows\NtUtil>raku -e "say 'h:/NotMyDocsBackup'.IO.d.Bool"
False

K:\Windows\NtUtil>raku -e "say 'h:/MyDocsBackup'.IO.d.Bool"
True


Thank you for the second pair of eyes!

-T

it is way more fun when I am not the one at fault


Re: I need help with IO.e

2020-05-16 Thread Peter Pentchev
On Sat, May 16, 2020 at 01:29:12PM +0200, Laurent Rosenfeld via perl6-users 
wrote:
> Hi,
> 
> it should be:
> 
> $ raku *-e* "your one-liner script here"

And also you might want to put some quotes around the paths to let Raku
know that those are strings and not some identifiers or something.

G'luck,
Peter

> Le sam. 16 mai 2020 à 12:16, ToddAndMargo via perl6-users <
> perl6-users@perl.org> a écrit :
> 
> > On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:
> > > Hi All,.
> > >
> > > Windows 7, sp1, x64
> > >
> > >  >raku -v
> > > This is Rakudo version 2020.01 built on MoarVM version
> > > 2020.01.1 implementing Perl 6.d.
> > >
> > >
> > > I am trying to get perl to tell me if a drive letter exists
> > >
> > > This is from Git's df command:
> > >
> > >  >df -kPT H:\
> > > Filesystem Type 1024-blocks  Used Available Capacity Mounted on
> > > H: ntfs   38908  9964 28944  26% /h
> > >
> > > So, H:\ is there
> > >
> > >  >raku "say H:\.IO.e"
> > > Could not open say H:\.IO.e. Failed to stat file: no such file or
> > directory
> > >
> > > And in case I need \\
> > >
> > >  >raku "say H:\\.IO.e"
> > > Could not open say H:\\.IO.e. Failed to stat file: no such file or
> > > directory
> > >
> > > And in case I need a forward slashL:
> > >  >raku "say H:/.IO.e"
> > > Could not open say H:/.IO.e. Failed to stat file: no such file or
> > directory
> > >
> > > What am I doing wrong, this time?
> > >
> > > -T
> > >
> >
> >
> > As far as I can tell IO.e and IO.d is completely trashed
> > in Windows:
> >
> > K:\Windows\NtUtil>dir H:
> >   Volume in drive H is BACKUP
> >   Volume Serial Number is 00D0-CAD4
> >
> >   Directory of H:\
> >
> > 05/15/2020  22:21 0 IAmBackup
> > 05/15/2020  22:43  MyDocsBackup
> > 1 File(s)  0 bytes
> > 1 Dir(s)  29,638,656 bytes free
> >
> >
> >
> > K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
> > Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such
> > file or di
> > rectory
> >
> > K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
> > Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such
> > file or directory
> >
> > K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
> > Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such
> > file or directory
> >
> > K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
> > Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such
> > file or directory
> >
> >
> > And that goes for IO.d too:
> >
> > K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
> > Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no such
> > file or
> >   directory
> >
> > K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
> > Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: no such
> > file or directory
> >
> > K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
> > Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: no such
> > file or directory
> >
> > K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
> > Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no such
> > file or  directory
> >
> > This gets a TRIPLE:  :'(  :'(  :'(
> >
> >
> >
> > And it only works slightly better under Fedora:
> >
> > $ p6 'say "GetOptLongTest.pl6".IO.e'
> > True
> >
> > $ p6 'say "GetOptLongTest.pl7".IO.e'
> > False
> >
> > $ p6 'say "p6lib".IO.d'
> > True
> >
> > $ p6 'say "p7lib".IO.d'
> > Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
> >in block  at -e line 1
> >
> > Notice that it crashed instead of returning a False.
> >
> > This gets a single :'(
> >
> >  AAHH 
> >

-- 
Peter Pentchev  r...@ringlet.net r...@debian.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: I need help with IO.e

2020-05-16 Thread Kevin Pye
There are three possibilities for the.d test -- the file exists and is a
directory, the files exists and is not a directory, and the file does not
exist. The test needs to distinguish between these three cases.

The documentation for .d states:

Returns True if the invocant is a path that exists and is a directory. The
method will fail  with
X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

(and by implication False if the file exists and is not a directory). In
other words it is behaving exactly as specified.

If you want to allow for the possibility that the file does not exist at
all, then you either need to catch the exception, or check for file
existence first.

Something like
'p7lib'.IO ~~ :e & :d
might work, although I haven't tested it.

Kevin.


On Sat, 16 May 2020 at 20:16, ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:
> > Hi All,.
> >
> > Windows 7, sp1, x64
> >
> >  >raku -v
> > This is Rakudo version 2020.01 built on MoarVM version
> > 2020.01.1 implementing Perl 6.d.
> >
> >
> > I am trying to get perl to tell me if a drive letter exists
> >
> > This is from Git's df command:
> >
> >  >df -kPT H:\
> > Filesystem Type 1024-blocks  Used Available Capacity Mounted on
> > H: ntfs   38908  9964 28944  26% /h
> >
> > So, H:\ is there
> >
> >  >raku "say H:\.IO.e"
> > Could not open say H:\.IO.e. Failed to stat file: no such file or
> directory
> >
> > And in case I need \\
> >
> >  >raku "say H:\\.IO.e"
> > Could not open say H:\\.IO.e. Failed to stat file: no such file or
> > directory
> >
> > And in case I need a forward slashL:
> >  >raku "say H:/.IO.e"
> > Could not open say H:/.IO.e. Failed to stat file: no such file or
> directory
> >
> > What am I doing wrong, this time?
> >
> > -T
> >
>
>
> As far as I can tell IO.e and IO.d is completely trashed
> in Windows:
>
> K:\Windows\NtUtil>dir H:
>   Volume in drive H is BACKUP
>   Volume Serial Number is 00D0-CAD4
>
>   Directory of H:\
>
> 05/15/2020  22:21 0 IAmBackup
> 05/15/2020  22:43  MyDocsBackup
> 1 File(s)  0 bytes
> 1 Dir(s)  29,638,656 bytes free
>
>
>
> K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
> Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such
> file or di
> rectory
>
> K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
> Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
> Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
> Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
>
> And that goes for IO.d too:
>
> K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
> Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no such
> file or
>   directory
>
> K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
> Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
> Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
> Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no such
> file or  directory
>
> This gets a TRIPLE:  :'(  :'(  :'(
>
>
>
> And it only works slightly better under Fedora:
>
> $ p6 'say "GetOptLongTest.pl6".IO.e'
> True
>
> $ p6 'say "GetOptLongTest.pl7".IO.e'
> False
>
> $ p6 'say "p6lib".IO.d'
> True
>
> $ p6 'say "p7lib".IO.d'
> Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
>in block  at -e line 1
>
> Notice that it crashed instead of returning a False.
>
> This gets a single :'(
>
>  AAHH 
>


Re: I need help with IO.e

2020-05-16 Thread Laurent Rosenfeld via perl6-users
Hi,

it should be:

$ raku *-e* "your one-liner script here"

Best regards,
Laurent.

Le sam. 16 mai 2020 à 12:16, ToddAndMargo via perl6-users <
perl6-users@perl.org> a écrit :

> On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:
> > Hi All,.
> >
> > Windows 7, sp1, x64
> >
> >  >raku -v
> > This is Rakudo version 2020.01 built on MoarVM version
> > 2020.01.1 implementing Perl 6.d.
> >
> >
> > I am trying to get perl to tell me if a drive letter exists
> >
> > This is from Git's df command:
> >
> >  >df -kPT H:\
> > Filesystem Type 1024-blocks  Used Available Capacity Mounted on
> > H: ntfs   38908  9964 28944  26% /h
> >
> > So, H:\ is there
> >
> >  >raku "say H:\.IO.e"
> > Could not open say H:\.IO.e. Failed to stat file: no such file or
> directory
> >
> > And in case I need \\
> >
> >  >raku "say H:\\.IO.e"
> > Could not open say H:\\.IO.e. Failed to stat file: no such file or
> > directory
> >
> > And in case I need a forward slashL:
> >  >raku "say H:/.IO.e"
> > Could not open say H:/.IO.e. Failed to stat file: no such file or
> directory
> >
> > What am I doing wrong, this time?
> >
> > -T
> >
>
>
> As far as I can tell IO.e and IO.d is completely trashed
> in Windows:
>
> K:\Windows\NtUtil>dir H:
>   Volume in drive H is BACKUP
>   Volume Serial Number is 00D0-CAD4
>
>   Directory of H:\
>
> 05/15/2020  22:21 0 IAmBackup
> 05/15/2020  22:43  MyDocsBackup
> 1 File(s)  0 bytes
> 1 Dir(s)  29,638,656 bytes free
>
>
>
> K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
> Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such
> file or di
> rectory
>
> K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
> Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
> Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
> Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such
> file or directory
>
>
> And that goes for IO.d too:
>
> K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
> Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no such
> file or
>   directory
>
> K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
> Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
> Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: no such
> file or directory
>
> K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
> Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no such
> file or  directory
>
> This gets a TRIPLE:  :'(  :'(  :'(
>
>
>
> And it only works slightly better under Fedora:
>
> $ p6 'say "GetOptLongTest.pl6".IO.e'
> True
>
> $ p6 'say "GetOptLongTest.pl7".IO.e'
> False
>
> $ p6 'say "p6lib".IO.d'
> True
>
> $ p6 'say "p7lib".IO.d'
> Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
>in block  at -e line 1
>
> Notice that it crashed instead of returning a False.
>
> This gets a single :'(
>
>  AAHH 
>


Re: I need help with IO.e

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-15 22:30, ToddAndMargo via perl6-users wrote:

Hi All,.

Windows 7, sp1, x64

 >raku -v
This is Rakudo version 2020.01 built on MoarVM version
2020.01.1 implementing Perl 6.d.


I am trying to get perl to tell me if a drive letter exists

This is from Git's df command:

 >df -kPT H:\
Filesystem Type 1024-blocks  Used Available Capacity Mounted on
H: ntfs   38908  9964 28944  26% /h

So, H:\ is there

 >raku "say H:\.IO.e"
Could not open say H:\.IO.e. Failed to stat file: no such file or directory

And in case I need \\

 >raku "say H:\\.IO.e"
Could not open say H:\\.IO.e. Failed to stat file: no such file or 
directory


And in case I need a forward slashL:
 >raku "say H:/.IO.e"
Could not open say H:/.IO.e. Failed to stat file: no such file or directory

What am I doing wrong, this time?

-T




As far as I can tell IO.e and IO.d is completely trashed
in Windows:

K:\Windows\NtUtil>dir H:
 Volume in drive H is BACKUP
 Volume Serial Number is 00D0-CAD4

 Directory of H:\

05/15/2020  22:21 0 IAmBackup
05/15/2020  22:43  MyDocsBackup
   1 File(s)  0 bytes
   1 Dir(s)  29,638,656 bytes free



K:\Windows\NtUtil>raku "say 'h://IAmBackup'.IO.e"
Could not open say 'h://IAmBackup'.IO.e. Failed to stat file: no such 
file or di

rectory

K:\Windows\NtUtil>raku "say 'h:/IAmBackup'.IO.e"
Could not open say 'h:/IAmBackup'.IO.e. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:\IAmBackup'.IO.e"
Could not open say 'h:\IAmBackup'.IO.e. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:\\IAmBackup'.IO.e"
Could not open say 'h:\\IAmBackup'.IO.e. Failed to stat file: no such 
file or directory



And that goes for IO.d too:

K:\Windows\NtUtil>raku "say 'h:\\MyDocsBackup'.IO.d"
Could not open say 'h:\\MyDocsBackup'.IO.d. Failed to stat file: no such 
file or

 directory

K:\Windows\NtUtil>raku "say 'h:\MyDocsBackup'.IO.d"
Could not open say 'h:\MyDocsBackup'.IO.d. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h:/MyDocsBackup'.IO.d"
Could not open say 'h:/MyDocsBackup'.IO.d. Failed to stat file: no such 
file or directory


K:\Windows\NtUtil>raku "say 'h://MyDocsBackup'.IO.d"
Could not open say 'h://MyDocsBackup'.IO.d. Failed to stat file: no such 
file or  directory


This gets a TRIPLE:  :'(  :'(  :'(



And it only works slightly better under Fedora:

$ p6 'say "GetOptLongTest.pl6".IO.e'
True

$ p6 'say "GetOptLongTest.pl7".IO.e'
False

$ p6 'say "p6lib".IO.d'
True

$ p6 'say "p7lib".IO.d'
Failed to find '/home/linuxutil/p7lib' while trying to do '.d'
  in block  at -e line 1

Notice that it crashed instead of returning a False.

This gets a single :'(

 AAHH 


I need help with IO.e

2020-05-15 Thread ToddAndMargo via perl6-users

Hi All,.

Windows 7, sp1, x64

>raku -v
This is Rakudo version 2020.01 built on MoarVM version
2020.01.1 implementing Perl 6.d.


I am trying to get perl to tell me if a drive letter exists

This is from Git's df command:

>df -kPT H:\
Filesystem Type 1024-blocks  Used Available Capacity Mounted on
H: ntfs   38908  9964 28944  26% /h

So, H:\ is there

>raku "say H:\.IO.e"
Could not open say H:\.IO.e. Failed to stat file: no such file or directory

And in case I need \\

>raku "say H:\\.IO.e"
Could not open say H:\\.IO.e. Failed to stat file: no such file or directory

And in case I need a forward slashL:
>raku "say H:/.IO.e"
Could not open say H:/.IO.e. Failed to stat file: no such file or directory

What am I doing wrong, this time?

-T

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