Re: Fancy sub arg handling: ability to expand error message?

2015-03-28 Thread The Sidhekin
On Sat, Mar 28, 2015 at 2:53 PM, Moritz Lenz mor...@faui2k3.org wrote:

 On 28.03.2015 12:27, Tom Browder wrote:
  I like the subroutine arg handling in Perl 6.  Is there any simple
  way to attach a short error msg in place of or additive to the
  default for, say, a missing arg?

 You can always use multi subs, and use a catch-all candidate which
 produces the error message.

 multi thingy($x) { $x + 42 }
 multi thingy(|c) { die Must call thingy with exactly one argument }


  Multis?  I guess my mind went elsewhere:

sidhekin@purplehat[00:25:02]~$ cat  tom.p6
sub foo($x = (warn foo called without argument; using default (42); 42)
) {
  $x + 42;
}

sub bar($x = (die bar called without argument; failing) ) {
  $x + 42;
}

say foo(-2);
say foo();
say bar(-2);
say bar();
sidhekin@purplehat[00:25:21]~$ perl6 tom.p6
40
foo called without argument; using default (42)  in sub foo at tom.p6:1

84
40
bar called without argument; failing
  in sub bar at tom.p6:5
  in block  at tom.p6:12

sidhekin@purplehat[00:25:27]~$


Eirik


Re: problem pushing pairs onto an array of pairs

2015-06-13 Thread The Sidhekin
On Sat, Jun 13, 2015 at 12:25 PM, mt1957 mt1...@gmail.com wrote:

 Can't push/unshift onto an array of pairs!

 Below a repl session with pushes

  my @p = a = 1, b = 2;

 a = 1 b = 2

 @p.push(x=1);

 a = 1 b = 2


  That's not pushing a pair – that's pushing nothing (no positionals) with
a named argument (name x, value 1).

  Pairs vs named arguments are going to be one of the confusing points
about perl6, right?

 @p.push((x=1));
a = 1 b = 2 x = 1


Eirik


Re: Strict Rakudo version of this Perl5 one-liner

2015-09-01 Thread The Sidhekin
On Tue, Sep 1, 2015 at 5:41 PM, Matija Papec  wrote:

> Scoping of lexical looks interesting
>
> perl6 -ne 'my %d; %d{ .words[1] }++; END { %d.sort.perl.say }'
>
> as this could not work in perl5
>
> perl -nE 'my $d =1; END { say $d//"default!" }' # gives default
>

  It's not the scoping.  It's scoped correctly, it's just that you need to
give it something to read, for the code to run, and the assignment to
happen:

$ echo | perl -nE 'my $d =1; END { say $d//"default!" }'
1
$ 

Re: Strict Rakudo version of this Perl5 one-liner

2015-09-02 Thread The Sidhekin
On Wed, Sep 2, 2015 at 7:49 AM, Matija Papec  wrote:

>
> I've picked a wrong example,
>
> seq 3 | perl -nE 'my %d; $d{$_}++; END { say keys %d }'
>
> vs
>
> seq 3 | perl6 -ne 'my %d; %d{$_}++;  END { say keys %d }'
>
> So it seems that perl6 handles lexicals inside while (<>){} one-liners
> differently.
>

  Ah, yes.  Interesting.  Run-time effect of C not happening
repeatedly.  How would that deparse?

  Compare:

$ seq 3 | perl6 -e 'for lines() { my %d; %d{$_}++; END { say keys %d } }'
3
$ seq 3 | perl6 -e 'for lines() { state %d; %d{$_}++; END { say keys %d } }'
1 2 3
$

  … and while I'm comparing:

$ seq 3 | perl6 -e 'for lines() { my %d; %d{$_}++; END { say keys %d } }'
3
$ seq 3 | perl -E 'while (<>) { my %d; $d{$_}++; END { say keys %d } }'
1

$

  … I need me a new mental model. :-)


Eirik


Re: maintainability and "or"

2017-03-21 Thread The Sidhekin
On Tue, Mar 21, 2017 at 7:28 PM, Brandon Allbery 
wrote:

> On Tue, Mar 21, 2017 at 7:50 AM, Elizabeth Mattijsen 
> wrote:
>
>>   $PathAndName.IO.open(:w).close unless $PathAndName.IO.f;
>
>
> This has a readability issue, though: you've buried the lede.


  Well, to me it seems the opposite: That condition does not exactly "entice
the reader to read the full story".  At least not this reader.

  The most significant/interesting info, in this reader's opinion, is not
the test of existence (and non-directoriness), but the creation of the file.

  Different folks. :)


Eirik, whose fingers first somehow autocompleted "test of time" while
trying to write "test of existence" …


Re: Any text editors for programming that support the secondary selection clipboard?

2017-06-21 Thread The Sidhekin
On Wed, Jun 21, 2017 at 1:35 PM, Luca Ferrari  wrote:

> > I like Geany, but it does not support the "Secondary Selection"
> > clipboard.  This clipboard would save me a bunch of time as
> > I would not lose my cursor hot spot.
>
> Emacs  Secondary-Selection.html>


  Out of the box, this will move the cursor ("placing point at the end of
the yanked text").  Precisely what the OP didn't want.

  But hey, emacs is nothing if not customizable. :)

  Just add to ~/.emacs (and eval the form, or restart emacs) the following
or something like it (TIMTOWTDI):

(advice-add 'mouse-yank-secondary :around
#'(lambda (orig-fun  args)
"Preserve point and mark and stuff"
(save-excursion
  (apply orig-fun args


Eirik


Re: takeWhile ?

2017-09-11 Thread The Sidhekin
On Mon, Sep 11, 2017 at 10:01 PM, Marc Chantreux  wrote:

> hello,
>
> doing maths with my kid, i just translated his spreadsheet with those
> lines of haskell:
>
> rebonds height loss = height : rebonds (height - height * loss)
> loss
> main = print $ takeWhile (> 2) $ rebonds 116 0.6
>
> then i wanted to make it as short as possible in perl6, i'm almost
> there:
>
> (116, * * .6  ... * < 2 ).say
>
> but the first $_ < 2 remains in the list. the only one alternative i see
> is a gather/take loop but i really expect something shorter from perl6
> :)
>

  Isn't this what ...^ is for?

(116, * * .6  ...^ * < 2 ).say;


Eirik


Re: Need match character help

2018-05-18 Thread The Sidhekin
On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen  wrote:

> character classes are fundamentally the wrong thing for "phrases", since
> they describe only a character.
>

  You were right the first time.


> Your current regex (before changing [gm] to ["gm"]) was expressing "from
> the start of the string, there's any amount of characters d through z (but
> neither g nor m) and then the end of the string", which can be more easily
> expressed as "the whole string contains only letters d through z (but
> neither g nor m)".
>
> What you apparently want is "the whole string contains only letters d
> through z, but never the phrase 'gm'", which - in order to get to a working
> regex - we can rephrase as "the whole string contains only letters d
> through z and no occurrence of g is followed by an m". Let's turn that into
> a regex:
>
> /^ # Require the match to start at the beginning of the
># string so nothing can sneak in before that.
> [  # Everything in this group will be matched a bunch
># of times.
> |  <[d..z]-[g]>  # either anything between d and z, with no
>  # further restrictions, except for g.
> |  g  # If there's a g, it must not be followed
>  # by an m.
> ]* # end of the group, allow the things in the group to
># occur any amount of times.
> $/ # Require the match to end at the end of the string,
># so nothing at the end can sneak in.
>
  Somewhat interesting exercise, but this kind of rephrasing doesn't scale
well for longer phrases, is hard to automate (given a phrase, which
character classes need we use?), and it's already pretty hard to read.

  If this requirement needs to be expressed in a single regex, here's what
I'd use (quickly translated from Perl5, then tested to get rid of
translation errors):

  / ^ <[d..z]>* $/

  ... or, with comments:

  / # not containing the phrase "gm" anywhere from here,
   ^ <[d..z]>* $ # match the whole string, containing only letters d
through z
  /


Eirik


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 8:01 AM, Todd Chester  wrote:

>
>
> On 06/13/2018 12:27 PM, Brandon Allbery wrote:
>
>> use MONKEY-SEE-NO-EVAL;
>>
>
> Thank you.  Someone had fun with that name!
>
> Do I presume there is not other way around the issue?
>

  That depends on your use case.  EVAL/eval is powerful enough it could be
pretty much anything, so bird's-eye view here:

  If $RunSpecific is sufficiently non-generic (i.e. couldn't be any code
whatsoever), an approach with dispatch tables or similar (dynamic method
lookup, giant switch ...) might be an alternative.  Optionally parsing the
code (Perl subset, DSL?) yourself.

  For use with any code whatsoever though, you need that kind of power, and
as Brandon wrote: You get to do your own data sanitization, and you tell
Perl 6 you did so with "use MONKEY-SEE-NO-EVAL;".


Eirik


Re: Malformed UTF-8?

2018-06-16 Thread The Sidhekin
On Sat, Jun 16, 2018 at 5:19 PM, Brandon Allbery 
wrote:

> Something's wrong with the data file you are reading. Perl 6 is expecting
> UTF-8 encoding and getting something else (usually an ISO-8859 encoding).
>

  Are you sure it's a data file?  I thought I recognized that code, and it
was handling directory entries ... ah, but it used to read ls output from
STDIN ... right ...

  Either way, the data (file or directory) has been read already, unless
@Logs is seriously lazy.  And it has at least one entry with malformed
UTF-8.

  So, I guess a look at how @Logs is populated is in order.


Eirik


Re: stackoverflow vs the world (and perl6-users)

2018-06-12 Thread The Sidhekin
On Tue, Jun 12, 2018 at 9:18 PM, Brad Gilbert  wrote:

> On Tue, Jun 12, 2018 at 1:19 PM, Joseph Brenner  wrote:
> > Attention conservation:  it's unlikely I'm going to say something
> > interesting you haven't thought of already.
> >
> > A side-discussion that came up here: should you ask questions here, or
> > at stackoverflow (or both here *and* at stackoverflow).
> >
> > I understand the argument that it's better to talk about perl in
> > public where non-perl might see it (to help counter that "perl is
> > dead" impression that's floating around).  Getting more involved with
> > stackoverflow has been on my list for a long time... and yet I haven't
> > gotten to it.  Why not?
> >
> > (1) The barrier at stackoverflow to a beginner is probably higher than
> > you think it is-- it's not at all obvious what you're allowed to do
> > and what you're not at the outset.
>
> The barrier is non-existent.
>


  Your failure of imagination does not make that barrier any less real.



Eirik


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:57 PM, Brandon Allbery 
wrote:

> You can never be certain in *any* case. Check if you're not sure what it
> means. Because sometimes languages use some term in a way you don't expect,
> whether because they drew it from some specific discipline (Haskell uses a
> lot of terminilogy from abstract mathematics, for example) or for some
> reason (I've hit a few cases where the language author didn't know the
> actual meaning of some term and used it "oddly" as a result).
>
> https://docs.perl6.org/language/glossary
>
> Which doesn't have "pragma" in it, probably because it's not specific to
> Perl. It's been around, and used in this sense, since at least the 1960s
> and probably earlier.
>

  ... but does have "whitespace" and "variable" in it, neither of which is
specific to Perl. :-P

  Isn't the lack of "pragma" there an omission to be corrected?

  Particularly if the term is required for the reading of error messages?


Eirik


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:21 PM, ToddAndMargo  wrote:

> 2) what the heck is a "pragma"?  Way to obscure.
>

  I thought you knew.  From the Perl 5 documentation: "A pragma is a module
which influences some aspect of the compile time or run time behaviour of
Perl, such as strict or warnings."

  More relevant, Perl 6 documentation:
https://docs.perl6.org/language/pragmas

  Now, I'm not sure how I would have responded to such an error message if
I wasn't already familiar with the term.  Search the web for Perl6 +
pragma, perhaps?

  Just thinking out loud: This hint ("use the MONKEY-SEE-NO-EVAL pragma to
override this error, but only if you're VERY sure your data contains no
injection attacks") is rather terse for those who need it ... might it be
better if the error message instead referenced documentation?


Eirik


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 7:46 PM, ToddAndMargo  wrote:

> On 06/14/2018 10:43 AM, The Sidhekin wrote:
>
>>
>>More relevant, Perl 6 documentation: https://docs.perl6.org/languag
>> e/pragmas
>>
>
> You are presuming I knew the word was a Perl word.
> I though it was English, as in pragmatic
>

  Not my intention.  This was just informing you where it is documented,
not presuming any prior knowledge.

  (The next line may be more presumptuous: "Now, I'm not sure how I would
have responded to such an error message if I wasn't already familiar with
the term.  Search the web for Perl6 + pragma, perhaps?"

  ... but also uncertain ... and in any case referring to my own self
specifically.)


Eirik


Re: EVAL?

2018-06-14 Thread The Sidhekin
On Thu, Jun 14, 2018 at 6:11 PM, Timo Paulssen  wrote:

> If it's literally just the name of a sub that you'll immediately invoke,
> you can side-step EVAL completely
>
> ::('&' ~ $RunSpecific)()
>
> should do the trick.
>

  I haven't been much into Perl 6 lately, but isn't this just the same as

&::($RunSpecific)()

... which is easier on these old eyes?


Eirik


Re: Appropriate last words

2018-09-03 Thread The Sidhekin
On Mon, Sep 3, 2018 at 10:50 PM Curt Tilmes  wrote:

> On Mon, Sep 3, 2018 at 4:28 PM Parrot Raiser <1parr...@gmail.com> wrote:
>
>> If I understand that correctly, "die" needs to be documented as always
>> outputting the line number, and that for user-oriented messages, one
>> of the other techniques should be used.
>>
>
> die throws the Exception -- you can CATCH it and handle it how you like,
> including printing the message without line numbers.
>

  Indeed, it is not C that outputs the line numbers: It is the default
exception handler.

Eirik


Re: Could this be any more obscure?

2018-09-26 Thread The Sidhekin
On Wed, Sep 26, 2018 at 8:58 AM Todd Chester  wrote:

> Hi All,
>
> Over on
>  https://docs.perl6.org/routine/words
> I see
>
> multi method words(Str:D $input: $limit = Inf --> Positional)
>
> HOW IN THE WORLD did they convert `$limit = Inf` into an
> array index!?!?!
>

  It's not.  It's a limit:

eirik@greencat[19:41:18]~$ perl6 -e '.say for "foo bar baz qux".words(2)'
foo
bar
eirik@greencat[19:41:29]~$

  I see from your other email that you're using square brackets.  That's
what makes a zero-based index:

eirik@greencat[19:41:29]~$ perl6 -e '.say for "foo bar baz qux".words[2]'
baz
eirik@greencat[19:43:00]~$

  But this index is not an argument to the words method.  It is an argument
to the .[ ] postcircumfix.

  That these are different things is perhaps more easily seen when they're
both present:

eirik@greencat[19:45:54]~$ perl6 -e '.say for "foo bar baz
qux".words(3)[*-1]'
baz
eirik@greencat[19:45:59]~$

  Here, it may be clearer that the $limit is 3, and the index is *-1.


Eirik


Re: Could this be any more obscure?

2018-09-26 Thread The Sidhekin
On Wed, Sep 26, 2018 at 11:40 PM ToddAndMargo  wrote:

> What I don't understand is:
>
>   multi method words(Str:D $input: $limit = Inf --> Positional)
>
> Specifically "$limit = Inf".  Why are we using "$limit" instead
> of "$selection"
>

  Perhaps this would be easier if you explain where you're getting
"$selection", and what you think it is.

And where is it stated what goes in the () and what goes
> in the []?
>

  The () is part of a method call syntax; method arguments go there:
https://docs.perl6.org/language/syntax#Subroutine_calls

  The [] is a postcircumfix operator; index arguments go there:
https://docs.perl6.org/language/operators#postcircumfix_[_]


Eirik


Re: Could this be any more obscure?

2018-09-26 Thread The Sidhekin
On Thu, Sep 27, 2018 at 3:03 AM ToddAndMargo  wrote:

> On 9/26/18 5:55 PM, Curt Tilmes wrote:
> > You are calling [] on the thing that the methods return.
>
> Yes, I know.  And it is human readable too.  It is one of the
> many reasons I adore Perl 6.
>
> Where in
> multi method words(Str:D $input: $limit = Inf --> Positional)
> does it state that "words" will do that?


  "words" doesn't do that.  Read it again: "You are calling []".  "You".
Not "words".


Eirik


Re: Could this be any more obscure?

2018-09-26 Thread The Sidhekin
On Thu, Sep 27, 2018 at 2:49 AM ToddAndMargo  wrote:

> On 9/26/18 4:33 PM, The Sidhekin wrote:
> > On Wed, Sep 26, 2018 at 11:40 PM ToddAndMargo  > <mailto:toddandma...@zoho.com>> wrote:
>


> > And where is it stated what goes in the () and what goes
> > in the []?
> >
> >
> >The () is part of a method call syntax; method arguments go there:
> > https://docs.perl6.org/language/syntax#Subroutine_calls
>
> Where does it state that
>
> $ p6 '"a b c d e".words(3).say;'
> (a b c)
>
> means the first three words, starting at zero?
>

  https://docs.perl6.org/routine/words#class_Str says it returns "the same
as a call to $input.comb( / \S+ /, $limit ) would".

  https://docs.perl6.org/routine/comb#class_Str says it "returns a list of
non-overlapping matches limited to at most $limit matches".

  It doesn't say it returns the first such matches; maybe it should.

  It doesn't say "starting at zero", but then, why should it?  The first
three wouldn't be the first three if it skipped any, right?


>
> >The [] is a postcircumfix operator; index arguments go there:
> > https://docs.perl6.org/language/operators#postcircumfix_[_]
>
> Where does
>
>  multi method words(Str:D $input: $limit = Inf --> Positional)
>
> state that I can do such?
>

  It doesn't.  https://docs.perl6.org/language/operators#postcircumfix_[_]
does.


> I ask this because not all methods will take []
>

  Sure they will.  They might give you runtime errors, if the method
doesn't (at runtime) return something that does Positional, but they will
all take it.


> Also, where is it stated that
>
> $ p6 '"a b c d e".words(3)[ 2, 4 ].say;'
> (c Nil)
>
> will send the first three words to [2,4] ?
>

  It doesn't.  It shouldn't: There's no "sending".

  https://docs.perl6.org/language/operators#postcircumfix_[_] tells you it
calls postcircumfix:<[ ]> with a first argument of what the returned (the
first three words) and the remaining positional arguments 2, 4.


Eirik


Re: Could this be any more obscure?

2018-09-26 Thread The Sidhekin
On Thu, Sep 27, 2018 at 3:14 AM Peter Scott  wrote:

> On 9/26/2018 3:21 PM, ToddAndMargo wrote:
> > Do your really think any beginner would be able to figure out
> > "words" from the above?
>
> If the beginner had studied the metasyntax of function prototypes,
> probably.


  Yeah, that's where a beginner needs to begin, in order to learn Perl6
from the docs.

  Syntax, metasyntax, all sorts of basics ...


> I heard about people
> who claim to have taught themselves Perl 5 from the Camel instead of the
> Llama, but they are few and far between, and in any case, most of the
> Camel contains exposition, if dense.


  I learned Perl 5 from the man pages.  It was more fun than efficient, but
I could easily afford it: It was not (at the time) my job. :)

  But we're not all wired the same way.  This endeavour looks to me neither
fun nor efficient.


Eirik


Re: escape codes

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

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

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

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

Eirik


Re: buf to integer?

2019-02-08 Thread The Sidhekin
On Fri, Feb 8, 2019 at 7:36 AM Todd Chester via perl6-users <
perl6-users@perl.org> wrote:

> I am dealing with a Buf what includes 32 bit integers, but
> they are entered somewhat backwards as view with hexedit:
>
> AE 5D 5C 72 represents the number 725C5DAE
>
> This is what I have come up with to convert this type of
> number in a buffer to and integer
>
> $ p6 'my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72); my int32 $i=$x[3] +< 0x18
> +  $x[2] +< 0x10  +  $x[1] +< 0x08  +  $x[0];  say $x; say $i.base(0x10);'
>
> Buf:0x
> 725C5DAE
>
>
> Is there a more "elegant" way to do this?
>

  The "elegant" way I'd do it, is using unpack():
https://docs.perl6.org/routine/unpack

  It's experimental, so a declaration is needed, but Buf does Blob, so
otherwise, it's straight to the point:

$ perl6 -e 'use experimental :pack; my Buf $x=Buf.new(0xAE,0x5D,0x5C,0x72);
say $x.unpack("L").base(0x10);'
725C5DAE
$


Eirik


Re: List in regexp

2019-09-03 Thread The Sidhekin
On Tue, Sep 3, 2019 at 8:37 AM yary  wrote:

> I see.  And that's discussed here (had to really look for it):
>> https://docs.perl6.org/language/regexes#Quoted_lists_are_LTM_matches
>> At first I was looking further down in the "Regex interpolation"
>> section, where it's also touched on, though I kept missing it:
>> > When an array variable is interpolated into a regex, the regex engine
>> handles it like a | alternative of the regex elements (see the
>> documentation on embedded lists, above).
>
>
> Which brings up another area for improvement- maybe. A regexp interprets a
> list as alternation only when it's a literal quoted list < like this >, or
> embedded in the regexp as a @-sigilled variable.
>
> That set up an expectation for me- "oh a list in a regexp becomes an
> alternation of the list elements" - but interpolation meets that
> expectation inconsistently.
>
> The interpolation doc section states, for both forms of code interpolation
> $(code) and <{code}>, "Runs Perl 6 code inside the regex, and interpolates
> the stringified return value..."
>

  I missed this the first time (or I would have suggested a version without
the variable), but I think what you want is interpolation by way of @(code).

  eirik@greencat[14:04:06]~$ perl6
You may want to `zef install Readline` or `zef install Linenoise` or use
rlwrap for a line editor

To exit type 'exit' or '^D'
> my $comma-separated='abc,+';
abc,+
> say 'abc' ~~ / @( $comma-separated.split(',') ) /;
「abc」
> eirik@greencat[14:05:48]~$

  I'd argue it's better this way, since syntax has me expecting $(...) to
interpolate a scalar (even if produced from a list), and @(…) to
interpolate a list.


Eirik


Re: Variable character class

2019-09-03 Thread The Sidhekin
On Tue, Sep 3, 2019 at 8:18 PM William Michels 
wrote:

> PS Eirik, I think people might be referring to <{...}> as "pointy
> blocks", but I'm really not sure... .
>

  I'm pretty sure Perl6 pointy blocks still refer to block constructors
with signatures, like: C<< my $add = -> $a, $b = 2 { $a + $b }; >>

  Oh hey, there's an index for it:
https://docs.perl6.org/language/functions#index-entry-pointy_blocks

  (The indexed docs don't actually define the term though …)


Eirik


Re: Variable character class

2019-09-01 Thread The Sidhekin
On Mon, Sep 2, 2019 at 1:12 AM Joseph Brenner  wrote:

> I was just trying to run Simon Proctor's solution, and I see it
> working for Yary's first case, but not his more complex one with
> problem characters like brackets included in the list of characters.
>
> I don't really see how to fix it, in part because I'm not that
> clear on what it's actually doing... there's some sort of
> implicit alternation going on?
>
>
> sub contains( Str $chars, Str $_ ) {
>   m:g/<{$chars.comb}>+/
> };
>

  The "implicit" alternation comes from interpolating a list (of subrules,
see below).

That works for this case:
>
>   say contains('24680', '19584203');
>   # (「8420」)
>
> But on something like this it errors out:
>
>   say contains('+\/\]\[', 'Apple ][+//e'); # says ][+//
>

  … because it's trying to compile each (1-character) string as a subrule …

  To have the (1-character) strings used a literals, rather than compiled
as subrules, put them in an array instead of a block wrapped in angle
brackets:

sub contains( Str $chars, Str $_ ) {
  my @arr = $chars.comb;
  m:g/@arr+/
}


  (… hey, is there a word for "block wrapped in angle brackets"?)


Eirik


Re: Quoting issue in Windows

2019-12-02 Thread The Sidhekin
On Mon, Dec 2, 2019 at 11:07 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

>
> What is the world is the Q doing in Q'\'?
>

  https://docs.perl6.org/language/quoting

  It would be clearer to write it as Q[\], I guess.


Eirik


Re: words and separators question

2019-11-28 Thread The Sidhekin
On Thu, Nov 28, 2019 at 2:53 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> Is there a way I can tell words that I want "fg hi" to
> be considered one word?  A way to make the separator
> two or more spaces?
>

  I don't think you can pass a separator to words.   But you can specify a
separator with split:  I assume .split(/\s\s+/) will DWYW.

  … or .comb(/\S[\s?\S]+/) … obviously not a very readable choice in this
instance, mind …


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Mon, Jan 13, 2020 at 8:51 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 11:10, ToddAndMargo via perl6-users wrote:
> >
> > https://docs.raku.org/type/UInt
> > Subset UInt
> > Unsigned integer (arbitrary-precision)
> > The UInt is defined as a subset of Int:
> > my subset UInt of Int where {not .defined or $_ >= 0};
> > Consequently, it cannot be instantiated or subclassed;
> > however, that shouldn't affect most normal uses
>
> Trivia:
>
> In https://docs.raku.org/type/UInt, a cardinal (uint)
> is a subset
>

  Nope.  Case matters.  It's mixed case "UInt" (not "uint") that's a subset.


> In https://docs.raku.org/language/nativetypes, a
> cardinal (unit) gets their own "native type".
>

  … whereas (lower case) "uint" is a native type.

  Documentation is easier to understand if you read what it says, and not
what you expect it to say.


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Mon, Jan 13, 2020 at 10:46 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 12:43, The Sidhekin wrote:
>
> On Mon, Jan 13, 2020 at 8:51 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> In https://docs.raku.org/type/UInt, a cardinal (uint)
>> is a subset
>>
>
>   Nope.  Case matters.  It's mixed case "UInt" (not "uint") that's a
> subset.
>
>
> What makes you think I did not understand the documentation?
> Perhaps it is you who does not understand me?
>

  Your use of the term "uint" in reference to "UInt" is what makes me think
so.

  uint and UInt are different types – conceptually related, but with no
type relation between them – the document on UInt tells you nothing about
uint.

  So when you say "a cardinal (uint) is a subset", this is not taken from
the cited documentation, and appears to be taken from your own
misapprehension.


Eirik


Re: Bug to report: cardinal called an integer

2020-01-13 Thread The Sidhekin
On Tue, Jan 14, 2020 at 1:25 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2020-01-13 15:16, Laurent Rosenfeld via perl6-users wrote:
> > The way you consistently mixed up uint and Uint in the last hours,
> > despite having been warned about this mistake, also shows a lack of
> > proper consideration for the documentation.
>
> Now that is a mystery to me.  The documentation for UInt
> does not mention uint.   But UInt and uint act exactly
> the same and have exactly the same properties.


  See, this is exactly what I'm talking about: "Documentation is easier to
understand if you read what it says, and not what you expect it to say."

  Documentation does not say UInt and uint act exactly the same and have
exactly the same properties.

  That's your expectation.

  Ignore your expectations.  Read what the documentation says, not what you
expect it to say.

  It'll make more sense.


Eirik


Re: can't make from a S/// ?

2021-11-20 Thread The Sidhekin
On Sat, Nov 20, 2021 at 9:03 PM Marc Chantreux  wrote:

> > > method col:sym ($/) { .make ~S:g/'""'/"/ }
> > That's not working for me. I'm on Moar (2021.06).
>
> works for me with:
>

method col:sym ($_) { .make: ~S:g/'""'/"/ }
>

  Yeah, you got it wrong the first time.  To explicate, the key difference
is differently named parameters: ($/) vs ($_).


Eirik


Re: steps of a path

2022-09-07 Thread The Sidhekin
On Wed, Sep 7, 2022 at 6:27 PM Parrot Raiser <1parr...@gmail.com> wrote:

> >
> > That said, right now gmail is claiming whipupitude is misspelled...
> >
> An alternative is "whipitupitude" (the difference being the first "it".
>
> Given the examples I've seen over the years, there's a need for an
> opposite to "idiomatic", for programming that arrives at a solution by
> a Rube Goldberg/Heath Robinson sort of convoluted and unnecessary
> path, or utterly abuses the language in a fashion that contradicts its
> underlying purpose or philosophy (writing video games in sed or
> invoicing programs in Lisp). "Idiotmatic" suggests itself. :-)*
>

  Sure you don't want "idiosyncratic"?


Eirik


Re: $/ not always set after a regex match?

2022-12-30 Thread The Sidhekin
On Fri, Dec 30, 2022 at 8:51 PM Vadim Belman  wrote:

> It is not "untrue". The sequence you produced goes nowhere. Thus the sink
> context.
>

  "Sink context" is true.

  "Useless use" is debatable, at least.


Eirik