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 


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-us...@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 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-us...@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: fill in form

2020-05-16 Thread Peter Pentchev
On Fri, May 15, 2020 at 04:42:44PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-05-15 15:23, Peter Pentchev wrote:
> > On Fri, May 15, 2020 at 02:51:10PM -0700, ToddAndMargo via perl6-users 
> > wrote:
> > > On 2020-05-13 14:05, Peter Pentchev wrote:
> > > > So... I believe Timo gave you that as an example how to use a grid to
> > > > position the various controls (buttons, text labels, input fields).
> > > > You start there, you figure out what text labels, what input fields,
> > > > what buttons you need, and then you use the 03-grid.p6 example as a base
> > > > on how to do this with Raku and GTK+.
> > > 
> > > Actually, he showed me the end result, not how he did it.
> > > I really need to know how he did it
> > 
> > Um, what he showed you was not in any way related to GTK+; it was
> > an example of using grid layout in Cascading Style Sheets (CSS),
> > a widely-used extension to HTML for making webpages. His point was
> > to illustrate the *idea* of aligning buttons, text labels, and text
> > input boxes to a grid.
> > 
> > So you posted a screenshot of running the 03-grid.p6 example.
> > It showed a couple of buttons and a text label, and it aligned them in
> > the way described in the source code. Play around with it a bit, move
> > the buttons and the text labels around, create another element or two,
> > look at the other examples, maybe the one that says "Hello World", maybe
> > the one that is called "text", see what other types of GTK+ things you
> > can put onto the grid.
> 
> With the exception that I do not know how to get the
> data back out of the pop up.  The example does not even
> have a `okay` and `cancel` button

...so, as I said, you look at the other examples. This one is merely
an example of aligning things, not of making things do something.
That's what the other examples (like the ones that, I don't know, maybe
the ones that I mentioned?).

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: Matching subpatterns in any order, conjunctions, negated matches

2020-05-16 Thread Peter Pentchev
On Fri, May 15, 2020 at 07:32:50PM -0700, Joseph Brenner wrote:
> Regex engines by their nature care a lot about order, but I
> occasionally want to relax that to match for multiple
> multicharacter subpatterns where the order of them doesn't
> matter.
> 
> Frequently the simplest thing to do is just to just do multiple
> matches.   Let's say you're looking for words that have a "qu" a
> "th" and also, say an "ea".  This works:
> 
>   my $DICT  = "/usr/share/dict/american-english";
>   my @hits = $DICT.IO.open( :r ).lines.grep({/qu/}).grep({/th/}).grep({/ea/});
>   say @hits;
>   # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's
> earthquakes]

Would something like this work for you?

  /^/

> Where things get interesting is when you want a negated match of
> one of the subpatterns.  One of the things I like about the first
> approach using multiple chained greps is that it's easy to do a
> reverse match.  What if you want words with "qu" and "th" but
> want to *skip* ones with an "ea"?
> 
>   my @hits = $DICT.IO.open( :r 
> ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/});
>   # [Asquith discotheque discotheque's discotheques quoth]

Maybe something like this? (note the "!" instead of "?")

  /^/

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 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-us...@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: Matching subpatterns in any order, conjunctions, negated matches

2020-05-16 Thread William Michels via perl6-users
On Fri, May 15, 2020 at 7:33 PM Joseph Brenner  wrote:
>
> Regex engines by their nature care a lot about order, but I
> occasionally want to relax that to match for multiple
> multicharacter subpatterns where the order of them doesn't
> matter.
>
> Frequently the simplest thing to do is just to just do multiple
> matches.   Let's say you're looking for words that have a "qu" a
> "th" and also, say an "ea".  This works:
>
>   my $DICT  = "/usr/share/dict/american-english";
>   my @hits = $DICT.IO.open( :r ).lines.grep({/qu/}).grep({/th/}).grep({/ea/});
>   say @hits;
>   # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's
> earthquakes]
>
>
> It could be useful to be able to do it as one match though, for
> example, you might be using someone else's routine which takes a
> single regex as argument.  I've been known to write things like
> this:
>
>   my regex qu_th_ea   {  [ qu .*? th .*? ea ] |
>  [ qu .*? ea .*? th ] |
>  [ th .*? qu .*? ea ] |
>  [ th .*? ea .*? qu ] |
>  [ ea .*? th .*? qu ] |
>  [ ea .*? qu .*? th ]  };
>   my @hits = $DICT.IO.open( :r ).lines.grep({//});
>
> That works, but it gets unwieldy quickly if you need to scale up
> the number of subpatterns.
>
> Recently though, I noticed the "conjunctions" feature, and it
> occured to me that this could be a very neat way of handling
> these things:
>
>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* & .* ea .* ] $ };
>
> That's certainly much better, though unfortunately each element
> of the conjunction needs to match a substring of the same length,
> so pretty frequently you're stuck with the visual noise of
> bracketing subpatterns with pairs of .*
>
> Where things get interesting is when you want a negated match of
> one of the subpatterns.  One of the things I like about the first
> approach using multiple chained greps is that it's easy to do a
> reverse match.  What if you want words with "qu" and "th" but
> want to *skip* ones with an "ea"?
>
>   my @hits = $DICT.IO.open( :r 
> ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/});
>   # [Asquith discotheque discotheque's discotheques quoth]
>
> To do that in one regex, it would be nice if there were some sort
> of adverb to do a reverse match, like say :not, then it
> would be straight-forward (NOTE: NON-WORKING CODE):
>
>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* &  [ :not .* ea .* ] ] $ };
>
> But since there isn't an adverb like this, what else might we do?
> The best idea I can come up with is this:
>
>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* &  [  . ]*  ] $ };
>
> Where the third element of the conjunction should match only if
> none of the characters follow "ea".  There's an oddity here
> though in that I think this can get confused by things like an
> "ea" that *precedes* the conjunction.
>
> So, the question then is: is there a neater way to embed a
> subpattern in a regex that does a negated match?

My two cents: Here's that Github issue Yary opened on creating custom
character classes. Some ideas expressed may be useful for figuring out
how to do a "negative regex":

https://github.com/Raku/problem-solving/issues/97

One take-home message that I've ascertained from the github discussion
above is that Raku/Perl6 regexes are run "wide-open" across all
umpteen Unicode hyperplanes (blocks/scripts), i.e. for a 'positive'
regex, matches will only be limited by the source document you're
scanning against. So the match below against Bengali digits works
right out of the box (REPL below):

> say $/ if '০১২৩৪৫৬৭৮৯' ~~ / \d+ /;
「০১২৩৪৫৬৭৮৯」
>

Negative regexes are more problematic: with the example above, do you
really want to return all "non-digit" characters? Or only alphanumeric
characters without the numeric component? Or only English ('Latin')
alphanumeric characters without the numeric component?

> say $/ if '০১২৩৪৫৬৭৮৯' ~~ / <-[\d]>+ /;
()
> say $/ if 'অআই ০১২৩৪৫৬৭৮৯' ~~ / <-[\d]>+ /;
「অআই 」
>

Above the Bengali letters "a", "aa", and "i" are (correctly) returned
by the second regex test. However in the contrived example below,
where I intersperse Latin letters with Bengali numbers ('a০b১c২') and
wrap the construct in angle brackets, I see a match of
"Latin-non-digits" adjacent to "non-Latin-digits". This says to me
that the call to (filter of) "<:Script" does NOT distribute
over the two different digit requirements, "-[\d]" and "+[\d]".
Moreover, I don't know HOW to get it to distribute over the two
different digit requirements, even if I "expand" the regex:

> say $/ if 'a০b১c২' ~~ / <:Script-[\d]+[\d]>+ /;
「a০b১c২」
> say $/ if 'a০b১c২' ~~ / <:Script-[\d]> <:Script+[\d]> /;
「a০」
>

Anyway Joseph, I like your point about using a conjunction and/or
adverb to do a reverse match. I just: 1) wanted to expand the
conversation to Unicode scripts/blocks, and 2) I posted the contrived
("interspersed") examples above in the hope that someone will

Re: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users

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

And what is `2 * 100 ** 2000 `?  Is that `(2 x 100)^ 2000`
((2 times 100) to the 2000 power?

Point 1: exponentiation has a higher priority than multiplication.

Point 2:https://rosettacode.org/wiki/Integer_roots


Any chance of you answering the question directly?

Is it (2 x 100)^ 2000

Or 2 x ( 100^ 2000 )2 times (100 to the 2000 power)?

Your point 1 only applies if it is an exponent.  Is the
2000 an exponent?  Does ** stand for exponent?


Re: sqrt and Buf question

2020-05-16 Thread William Michels via perl6-users
Hi Todd,

Yes, ** stands for exponentiation. And exponentiation has higher
precedence than multiplication. See below (I dropped a few zeros to
help clarify):

> put 2 * 10 ** 20
2
> put (2 * 10) ** 20
1048576
> put 2 * (10 ** 20)
2
> 20 ** 20
1048576
>

https://docs.raku.org/language/operators

HTH, Bill.


On Sat, May 16, 2020 at 2:33 PM ToddAndMargo via perl6-users
 wrote:
>
> On 2020-05-14 22:26, Peter Pentchev wrote:
> >> And what is `2 * 100 ** 2000 `?  Is that `(2 x 100)^ 2000`
> >> ((2 times 100) to the 2000 power?
> > Point 1: exponentiation has a higher priority than multiplication.
> >
> > Point 2:https://rosettacode.org/wiki/Integer_roots
>
> Any chance of you answering the question directly?
>
> Is it (2 x 100)^ 2000
>
> Or 2 x ( 100^ 2000 )2 times (100 to the 2000 power)?
>
> Your point 1 only applies if it is an exponent.  Is the
> 2000 an exponent?  Does ** stand for exponent?


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-us...@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 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: sqrt and Buf question

2020-05-16 Thread ToddAndMargo via perl6-users

On 2020-05-16 14:48, William Michels via perl6-users wrote:

Yes, ** stands for exponentiation


Thank you!


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 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: Matching subpatterns in any order, conjunctions, negated matches

2020-05-16 Thread Joseph Brenner
This is pretty interesting, though I think you're talking about a
different subject... I was talking about cases where the
sub-patterns are more than one character long.  It's true that if
you were interested in single-character sub-patterns, then you
could get close with character classes and negated character
classes.  For example, suppose you were not only interested in
matching the word "the" but you were also interested in finding
it even if it had typos like "teh" or "hte" or something.  Then a
pattern like /<[the]>**3/ would definitely find every permutation
of "t", "h", and "e", and it could be it's good enough for you,
butit would also match cases with duplications like "ttt", "hhh",
"thh" and so on, so it's a broader match than the techniques I
was talking about (it gets the combinations, not just the
permutations).


On 5/16/20, William Michels  wrote:
> On Fri, May 15, 2020 at 7:33 PM Joseph Brenner  wrote:
>>
>> Regex engines by their nature care a lot about order, but I
>> occasionally want to relax that to match for multiple
>> multicharacter subpatterns where the order of them doesn't
>> matter.
>>
>> Frequently the simplest thing to do is just to just do multiple
>> matches.   Let's say you're looking for words that have a "qu" a
>> "th" and also, say an "ea".  This works:
>>
>>   my $DICT  = "/usr/share/dict/american-english";
>>   my @hits = $DICT.IO.open( :r
>> ).lines.grep({/qu/}).grep({/th/}).grep({/ea/});
>>   say @hits;
>>   # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's
>> earthquakes]
>>
>>
>> It could be useful to be able to do it as one match though, for
>> example, you might be using someone else's routine which takes a
>> single regex as argument.  I've been known to write things like
>> this:
>>
>>   my regex qu_th_ea   {  [ qu .*? th .*? ea ] |
>>  [ qu .*? ea .*? th ] |
>>  [ th .*? qu .*? ea ] |
>>  [ th .*? ea .*? qu ] |
>>  [ ea .*? th .*? qu ] |
>>  [ ea .*? qu .*? th ]  };
>>   my @hits = $DICT.IO.open( :r ).lines.grep({//});
>>
>> That works, but it gets unwieldy quickly if you need to scale up
>> the number of subpatterns.
>>
>> Recently though, I noticed the "conjunctions" feature, and it
>> occured to me that this could be a very neat way of handling
>> these things:
>>
>>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* & .* ea .* ] $ };
>>
>> That's certainly much better, though unfortunately each element
>> of the conjunction needs to match a substring of the same length,
>> so pretty frequently you're stuck with the visual noise of
>> bracketing subpatterns with pairs of .*
>>
>> Where things get interesting is when you want a negated match of
>> one of the subpatterns.  One of the things I like about the first
>> approach using multiple chained greps is that it's easy to do a
>> reverse match.  What if you want words with "qu" and "th" but
>> want to *skip* ones with an "ea"?
>>
>>   my @hits = $DICT.IO.open( :r
>> ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/});
>>   # [Asquith discotheque discotheque's discotheques quoth]
>>
>> To do that in one regex, it would be nice if there were some sort
>> of adverb to do a reverse match, like say :not, then it
>> would be straight-forward (NOTE: NON-WORKING CODE):
>>
>>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* &  [ :not .* ea .* ] ] $ };
>>
>> But since there isn't an adverb like this, what else might we do?
>> The best idea I can come up with is this:
>>
>>   my regex qu_th_ea { ^ [ .* qu .* & .* th .* &  [  . ]*  ] $
>> };
>>
>> Where the third element of the conjunction should match only if
>> none of the characters follow "ea".  There's an oddity here
>> though in that I think this can get confused by things like an
>> "ea" that *precedes* the conjunction.
>>
>> So, the question then is: is there a neater way to embed a
>> subpattern in a regex that does a negated match?
>
> My two cents: Here's that Github issue Yary opened on creating custom
> character classes. Some ideas expressed may be useful for figuring out
> how to do a "negative regex":
>
> https://github.com/Raku/problem-solving/issues/97
>
> One take-home message that I've ascertained from the github discussion
> above is that Raku/Perl6 regexes are run "wide-open" across all
> umpteen Unicode hyperplanes (blocks/scripts), i.e. for a 'positive'
> regex, matches will only be limited by the source document you're
> scanning against. So the match below against Bengali digits works
> right out of the box (REPL below):
>
>> say $/ if '০১২৩৪৫৬৭৮৯' ~~ / \d+ /;
> 「০১২৩৪৫৬৭৮৯」
>>
>
> Negative regexes are more problematic: with the example above, do you
> really want to return all "non-digit" characters? Or only alphanumeric
> characters without the numeric component? Or only English ('Latin')
> alphanumeric characters without the numeric component?
>
>> say $/ if '০১২৩৪৫৬৭৮৯' ~~ / <-[\d]>+ /;
> ()
>> say $/ if 'অআই ০১২৩

Re: Matching subpatterns in any order, conjunctions, negated matches

2020-05-16 Thread Joseph Brenner
Yes, both of those work, and arguably they're a little cleaner
looking than my conjunction approach-- though it's not necessarily any
easier to think about.  It looks like a pattern that's matching
for three things in order, but the zero-widthness of the "before"
let's them all work on top of each other.

I keep thinking there's an edge case in these before/after tricks that
might matter if we weren't matching the one-word-per-line format of
the unix dictionaries, but I need to think about that a little more...



 Peter Pentchev  wrote:
> On Fri, May 15, 2020 at 07:32:50PM -0700, Joseph Brenner wrote:
>> Regex engines by their nature care a lot about order, but I
>> occasionally want to relax that to match for multiple
>> multicharacter subpatterns where the order of them doesn't
>> matter.
>>
>> Frequently the simplest thing to do is just to just do multiple
>> matches.   Let's say you're looking for words that have a "qu" a
>> "th" and also, say an "ea".  This works:
>>
>>   my $DICT  = "/usr/share/dict/american-english";
>>   my @hits = $DICT.IO.open( :r
>> ).lines.grep({/qu/}).grep({/th/}).grep({/ea/});
>>   say @hits;
>>   # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's
>> earthquakes]
>
> Would something like this work for you?
>
>   /^/
>
>> Where things get interesting is when you want a negated match of
>> one of the subpatterns.  One of the things I like about the first
>> approach using multiple chained greps is that it's easy to do a
>> reverse match.  What if you want words with "qu" and "th" but
>> want to *skip* ones with an "ea"?
>>
>>   my @hits = $DICT.IO.open( :r
>> ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/});
>>   # [Asquith discotheque discotheque's discotheques quoth]
>
> Maybe something like this? (note the "!" instead of "?")
>
>   /^/
>
> 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: Matching subpatterns in any order, conjunctions, negated matches

2020-05-16 Thread Peter Pentchev
On Sat, May 16, 2020 at 05:53:04PM -0700, Joseph Brenner wrote:
>  Peter Pentchev  wrote:
> > On Fri, May 15, 2020 at 07:32:50PM -0700, Joseph Brenner wrote:
> >> Regex engines by their nature care a lot about order, but I
> >> occasionally want to relax that to match for multiple
> >> multicharacter subpatterns where the order of them doesn't
> >> matter.
> >>
> >> Frequently the simplest thing to do is just to just do multiple
> >> matches.   Let's say you're looking for words that have a "qu" a
> >> "th" and also, say an "ea".  This works:
> >>
> >>   my $DICT  = "/usr/share/dict/american-english";
> >>   my @hits = $DICT.IO.open( :r
> >> ).lines.grep({/qu/}).grep({/th/}).grep({/ea/});
> >>   say @hits;
> >>   # [bequeath bequeathed bequeathing bequeaths earthquake earthquake's
> >> earthquakes]
> >
> > Would something like this work for you?
> >
> >   /^/
> >
> >> Where things get interesting is when you want a negated match of
> >> one of the subpatterns.  One of the things I like about the first
> >> approach using multiple chained greps is that it's easy to do a
> >> reverse match.  What if you want words with "qu" and "th" but
> >> want to *skip* ones with an "ea"?
> >>
> >>   my @hits = $DICT.IO.open( :r
> >> ).lines.grep({/qu/}).grep({/th/}).grep({!/ea/});
> >>   # [Asquith discotheque discotheque's discotheques quoth]
> >
> > Maybe something like this? (note the "!" instead of "?")
> >
> >   /^/
> >
>
> Yes, both of those work, and arguably they're a little cleaner
> looking than my conjunction approach-- though it's not necessarily any
> easier to think about.  It looks like a pattern that's matching
> for three things in order, but the zero-widthness of the "before"
> let's them all work on top of each other.
> 
> I keep thinking there's an edge case in these before/after tricks that
> might matter if we weren't matching the one-word-per-line format of
> the unix dictionaries, but I need to think about that a little more...

Actually, there is, and I conveniently did not mention it :) It's the
case when the patterns may overlap: if you do the '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 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