Re: Need regex ^? help

2024-04-29 Thread Patrick R. Michaud
Perhaps not really what you're intending, but here's how I'd start: $ raku -e 'my $x="1.2.3.4"; $x ~~ s!\d+$!0/24!; say $x;' 1.2.3.0/24 The pattern part of the substitution matches all of the digits at the end of the string (\d+$), then replaces them with the string "0/24". Everything p

Re: how do I turn a real into and array of Integers?

2021-11-01 Thread Patrick R. Michaud
This is a place where .comb() is likely much better than .split() -- .comb() allows you to specify what you're wanting instead of what you're wanting to avoid: $ raku -e "say sqrt(2).comb(/\d/).join(', ');" 1, 4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 1 If you want only the first 10 di

Re: intermixed types and resulting types

2021-08-21 Thread Patrick R. Michaud
On Sat, Aug 21, 2021 at 12:50:21PM -0700, Joseph Brenner wrote: > But then, in a case like this one, how would you know in advance > that it would work, without Just Trying It: > > my @monsters = < godzilla grendel wormface blob >; > my $cool_monsters = < godzilla ghidra mothera >.Set; >

Re: callbacks with placeholder vars

2021-08-09 Thread Patrick R. Michaud
On Mon, Aug 09, 2021 at 01:00:52PM -0700, Joseph Brenner wrote: > There's this much: > > https://docs.raku.org/language/variables#index-entry-$$CIRCUMFLEX_ACCENT > > > If you have self-declared a parameter using $^a once, you may refer to it > > using only $a thereafter. > > But it doesn't go a

Re: [naive] hash assingment

2021-07-14 Thread Patrick R. Michaud
On Wed, Jul 14, 2021 at 07:41:14PM +, Daniel Sockwell wrote: > (Also, you may already know this, but when the keys of your hash are > strings, you can write %a instead of %a{'column1'} ) A minor nit: this only works if the string keys don't contain whitespace. (The single angle bracket postf

Re: I need help with ~~m/

2021-01-30 Thread Patrick R. Michaud
On Sat, Jan 30, 2021 at 05:52:54PM -0800, Joseph Brenner wrote: > Which means there's some potential confusion if you really need > to match quotes: > > my $str = 'string_632="The chicken says--", voice="high"'; > > say > $str ~~ m:g{ ( " .*? " ) }; # False > say > $str

Re: for and ^ question

2021-01-01 Thread Patrick R. Michaud
On Fri, Jan 01, 2021 at 05:41:04PM -0800, ToddAndMargo via perl6-users wrote: > On 1/1/21 6:32 AM, David Santiago wrote: > > say $_ for {0.1+$_}...^5 > > Is there a way to do this without the finger wagging? > > say $_ for {0.1+$_}...^2 If you're going to a sequence operator ("...") instead of a

Re: Missing NullPointerException

2020-12-01 Thread Patrick R. Michaud
The difference is between the result of "Nil.c" and "Any.c". On my current version of Rakudo, "Nil.c" returns Nil, while Any.c throws the "No such method" exception. In fact, Nil.any_non_existent method always seems to return Nil. I'm not sure where this is documented, but it's likely the re

Re: Brace interpolation in strings creates a new scope?

2020-10-26 Thread Patrick R. Michaud
On Mon, Oct 26, 2020 at 08:04:21PM +0100, Elizabeth Mattijsen wrote: > > On 26 Oct 2020, at 18:40, Sean McAfee wrote: > > Is this the intended behavior? The doc page on quoting constructs > > just says that values can be interpolated with braces, but (at least > > to my eyes) doesn't suggest th

Re: "ICU - International Components for Unicode"

2020-09-25 Thread Patrick R. Michaud
On Fri, Sep 25, 2020 at 12:37:49PM +0200, Elizabeth Mattijsen wrote: > > On 25 Sep 2020, at 04:25, Brad Gilbert wrote: > > Rakudo does not use ICU > > > > It used to though. > > > > Rakudo used to run on Parrot. > > Parrot used ICU for its Unicode features. > > I do remember that in the Parrot

Re: junctions and parenthesis

2020-06-21 Thread Patrick R. Michaud
The "any" function is just like any other function taking an arbitrary list of arguments (including user-defined functions). As such it parses with lower precedence than comparison operators -- so "eq" binds more tightly than "any". Thus say so any eq any ; parses like say(so(any( eq

Re: I need help sorting a list

2020-05-24 Thread Patrick R. Michaud
On Mon, May 25, 2020 at 12:07:22AM +0200, Tobias Boege wrote: > @things.sort: { > .comb(/ \d+ | \D+ /) > .map({ .Int // .self }) > } Or how about even somethig like @things.sort: *.Version; which does handle a reasonable set of version semantics...? (The .Version method was

Re: Help with grammar

2020-05-21 Thread Patrick R. Michaud
On Thu, May 21, 2020 at 08:40:08PM +, David Santiago wrote: > Can someone explain me why my grammar isn't working? Unfortunately i > can't figure it out :-( > > | headers > | | header > | | * MATCH "Proxy-Connection" > | | header-value > | | * MATCH "keep-alive\n" > | | crlf > | |

Re: Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread Patrick R. Michaud
"say $x" is essentially equivalent to "put $x.gist". Since Nil is undefined (roughly equivalent to a type object), Nil.gist has a string value of "Nil" and can be printed. However, attempting to convert Nil directly into a Str throws an error because that's attempting to stringify an undefined

Re: Metamethods: WHERE

2020-02-12 Thread Patrick R. Michaud
On Wed, Feb 12, 2020 at 10:27:20AM -0300, Aureliano Guedes wrote: > So, I'd like to find a way to test if two variables are bound or not, > especially concerning their memory address. > > If the address is not fixed for a lifetime, I must be able to test it in > just one cycle. > > $a.WHERE == $b.

Re: Substr behaviour with CRLF

2020-02-10 Thread Patrick R. Michaud
Because Str is treated as a set of graphemes, and "\r\n" is treated as a single character, .substr() is doing the right thing here. If you really want to treat it as a series of codepoints, you may want to go through Blob/Buf to get there: > "1234\r\n78".encode.subbuf(*-4) utf8:0x<0D 0A

Re: Teaching Rakudo the tricks of Perl 5's regex optimiser

2019-08-13 Thread Patrick R. Michaud
FWIW, at one time there was discussion that "" and "" are actually keywords and not typical method calls that can be overridden, precisely so optimizations can be made. They're that important to efficient running of the regexes. I'm not sure that a formal decision was ever made on this, however

Re: while(<>){...} analog?

2019-07-29 Thread Patrick R. Michaud
My guesses at Perl 6 versions of the Perl 5 example: say .split(':')[0, 2, 1, 5].join("\t") for lines; -or- for lines { say .split(':')[0, 2, 1, 5].join("\t") } Pm On Mon, Jul 29, 2019 at 12:49:51PM -0700, William Michels via perl6-users wrote: > Hello, Just a short backgrounder to say

Re: Need help with a regex

2019-05-07 Thread Patrick R. Michaud
The (.*?) pattern will match an empty string. Thus $0 gets the dollar sign, $1 is "", and "$" ~ "" (i.e., "$") gets replaced by "" ~ "USD" (i.e., "USD"). So the net result is to replace the single dollar sign by "USD", resulting in "USD1.23". You might want to remove the ? modifier from .*?

Re: split and nils?

2019-02-06 Thread Patrick R. Michaud
On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: > $ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> = > ord <" ~ ord($j) ~ ">";}' > > Index <0> = = ord <97> > Index <1> = = ord <98> > Index <2> = = ord <99> > Index <3> = = ord <100> > > Cer

Re: [perl #133541] Grammer bug vs

2018-09-28 Thread Patrick R. Michaud via RT
The issue doesn't seem to be the underscore, because I get the same result even when converting the underscore into a letter ('b'): $ cat gentb.p6 grammar G0 { token TOP {|.*} regex rport { } rule ruport { } #token type {+} token type {+} } grammar G1 {

Re: [perl #133541] Grammer bug vs

2018-09-28 Thread Patrick R. Michaud
The issue doesn't seem to be the underscore, because I get the same result even when converting the underscore into a letter ('b'): $ cat gentb.p6 grammar G0 { token TOP {|.*} regex rport { } rule ruport { } #token type {+} token type {+} } grammar G1 {

Re: Grammar doesn't seem to match any token

2018-09-23 Thread Patrick R. Michaud
I suspect the rule: rule other { . } means that in $input = '~i << to match (although will also end up matching the space after the "i" in the text string, since white spaces are no longer significant). Or try just changing the rule to be a token and leave the others as rules. Ph

Re: Catching exceptions in expressions

2018-08-03 Thread Patrick R. Michaud
we could use Thunk as a type: > > sub infix:(Thunk:D $block, $otherwise) { } > > which would then allow you to do: > > my $sixdivzero = divide(6,0) rescue -1; # note absence of curlies > > > > One can wish, can’t one? > > > Liz > > > On 3 Aug 2

Re: Catching exceptions in expressions

2018-08-03 Thread Patrick R. Michaud
Maybe something like...? $ cat t.p6 sub infix:(Callable $block, $otherwise) { CATCH { return $otherwise; } $block(); } sub divide($a, $b) { die "Zero denominator" if $b == 0; $a / $b } my $sixdivzero = { divide(6,0) } rescue -1; say "6/0 = ", $sixdivzero; my $sixdivtwo = { divide(6,2) }

Re: need regex help

2018-08-03 Thread Patrick R. Michaud
The + essentially indicates that this is a character-class match. It's to distinguish things from <.alpha>, , , <-alpha>, and (among others). Pm On Fri, Aug 03, 2018 at 08:48:24PM +0200, Timo Paulssen wrote: > The + is required, perhaps because the first character after the opening > < is sup

Re: can't match unicode chars?

2018-07-31 Thread Patrick R. Michaud
On Tue, Jul 31, 2018 at 09:28:08PM +0200, Marc Chantreux wrote: > @*ARGS.map: { > gather { > my @lines; > for .IO.lines -> $l { >if /'›'/ { >@lines and take @lines; >@lines = $l; >} >else { >@lin

Re: -c bug to report

2018-07-25 Thread Patrick R. Michaud
On Wed, Jul 25, 2018 at 11:48:30AM -0700, ToddAndMargo wrote: > Maybe I am trying to get "-c" to do too many things. > > What I would like it to do is to check everything right up to but not > actually run the program. Part of the challenge here is that unlike many other programming languages, P

Re: Need match character help

2018-05-20 Thread Patrick R. Michaud
On Sun, May 20, 2018 at 03:02:34PM -0700, ToddAndMargo wrote: > On 05/20/2018 10:40 AM, Patrick R. Michaud wrote: > > On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote: > > > On 18/05/18 13:30, The Sidhekin wrote: > > > > > > > >   / ^ &l

Re: Need match character help

2018-05-20 Thread Patrick R. Michaud
On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote: > On 18/05/18 13:30, The Sidhekin wrote: > > > >   / ^ <[d..z]>* $/ > > That's pretty good! Putting the beginning-of-string anchor ^ anywhere > but the very start is surely an advanced move :) FWIW, sometimes I think it's worth invert

Re: Naming debate- what's the location for it?

2018-02-14 Thread Patrick R. Michaud
On Wed, Feb 14, 2018 at 05:55:54PM +, raiph mellor wrote: > (Perl) Rakudo > === > > If jnthn and pmichaud and larry can warm to this idea, then: > [...] > The 'Perl' could be dropped from Rakudo specific propaganda, > calling the language just Rakudo instead, to reinforce that it refer

Re: Any "note" without the "say"?

2017-09-15 Thread Patrick R. Michaud
On Fri, Sep 15, 2017 at 04:54:33PM -0400, Brandon Allbery wrote: > On Fri, Sep 15, 2017 at 4:51 PM, ToddAndMargo wrote: > > On 09/15/2017 01:29 PM, Brandon Allbery wrote: > >> Everyone does at one time :) It's really useful for debugging, but you > >> generally strip it out of production code. > >

Re: [perl #132066] [BUG] Code blocks cause backtracking fail in `|` alternation with ratcheting

2017-09-11 Thread Patrick R. Michaud via RT
On Mon, Sep 11, 2017 at 09:48:01AM -0700, Dan Zwell wrote: > > `|` matches the longest input: > > 'ab' ~~ / ^:ratchet [ . | .. ] $ / > 「ab」 > > If the regex contains empty code blocks, backtracking fails: > > 'ab' ~~ / ^:ratchet [ {}. | {}.. ] $ / > Nil Isn't the whole point of :ratchet to turn

Re: [perl #132066] [BUG] Code blocks cause backtracking fail in `|` alternation with ratcheting

2017-09-11 Thread Patrick R. Michaud
On Mon, Sep 11, 2017 at 09:48:01AM -0700, Dan Zwell wrote: > > `|` matches the longest input: > > 'ab' ~~ / ^:ratchet [ . | .. ] $ / > 「ab」 > > If the regex contains empty code blocks, backtracking fails: > > 'ab' ~~ / ^:ratchet [ {}. | {}.. ] $ / > Nil Isn't the whole point of :ratchet to turn

Re: Need awk print sub

2017-08-04 Thread Patrick R. Michaud
How about... $ echo "a b c d" | ./perl6 -n -e '.words[1].say' b Pm On Fri, Aug 04, 2017 at 01:00:52PM -0700, ToddAndMargo wrote: > Hi All, > > How do I do this with a perl one liner? > > $ echo "a b c d" | awk '{print $2}' > b > > Many thanks, > -T

Re: Verifiable Releases/The Build System is Ridiculous

2017-07-27 Thread Patrick R. Michaud
The details of how to use the star GitHub repository are in tools/star/release_guide.pod . You're entirely welcome to create a bundling that has a better build system than what Rakudo Star uses -- indeed, Rakudo Star has always been intended to be just one of many possible bundlings of Rakudo a

Re: [perl #131708] [BUILD]. Rakudo Star build instructions incomplete

2017-07-05 Thread Patrick R. Michaud via RT
On Wed, Jul 05, 2017 at 06:10:42PM -0700, Will Coleda via RT wrote: > On Wed, 05 Jul 2017 09:16:44 -0700, tbrowder wrote: > > Given this invocation for a new installation of rakudo: > > > > perl Configure.pl --backend=moar --gen-moar --prefix=/some/dir > > > > /some/dir needs to exist and belo

Re: [perl #131708] [BUILD]. Rakudo Star build instructions incomplete

2017-07-05 Thread Patrick R. Michaud
On Wed, Jul 05, 2017 at 06:10:42PM -0700, Will Coleda via RT wrote: > On Wed, 05 Jul 2017 09:16:44 -0700, tbrowder wrote: > > Given this invocation for a new installation of rakudo: > > > > perl Configure.pl --backend=moar --gen-moar --prefix=/some/dir > > > > /some/dir needs to exist and belo

Re: getting help in the REPL

2017-06-14 Thread Patrick R. Michaud
On Wed, Jun 14, 2017 at 04:00:05PM +0300, Gabor Szabo wrote: > In the python interactive shell one can write dir(object) and it > lists the attributes and methods of the object. One can write > help(object) and get the documentation of the object. > Is there anything similar in Perl 6? I think th

Re: Perl6 shell, Was: command auto-completion in perl6 shell

2017-05-31 Thread Patrick R. Michaud
On Wed, May 31, 2017 at 09:33:59AM -0400, Brock Wilcox wrote: > One of my dreams is to adopt a client/server + middleware model from nREPL > (clojure) which I think works really well, and likely to do that in > userspace as a regular module. Moving everything into REPL.pm (perl6 > instead of nqp) l

Re: Invoking method by name found in variable

2017-05-23 Thread Patrick R. Michaud
On Tue, May 23, 2017 at 09:01:54PM +0300, Gabor Szabo wrote: > given an object $o and the name of a method in $method = "run" > how can I invoke the $o.run() ? > > Something like $o.call($method) At one point it was done as $o."$method"() . > my $method = 'say'; 123."$method"(); 123 Pm

Re: Parse a string into a regex?

2017-05-11 Thread Patrick R. Michaud
Since we went to a lot of trouble to get lexical and closures to work correctly in Perl 6, it seems fair to use it here: $ cat rxstr sub rxstr($s) { rx/<$s>/ } my $str = 'foo'; my $foorx = rxstr($str); # create /foo/ regex say 'foo' ~~ $foorx; # matches $

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:46:43PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 2:37 PM, Patrick R. Michaud > wrote: > > > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo > > wrote: > > > > $Name.IO.f or $Name.IO.open(:w).close; > > > > >

Re: maintainability and "or"

2017-03-21 Thread Patrick R. Michaud
On Tue, Mar 21, 2017 at 02:25:02PM -0400, Brandon Allbery wrote: > On Tue, Mar 21, 2017 at 7:38 AM, ToddAndMargo wrote: > > $Name.IO.f or $Name.IO.open(:w).close; > > fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly > poor one for readability and maintainability, but one

Re: RFE: throw an error on a single "="when used in an "if"

2017-03-20 Thread Patrick R. Michaud
On Mon, Mar 20, 2017 at 02:36:49PM +0100, Francesco Rivetti wrote: > On 18. mars 2017 11:54, Elizabeth Mattijsen wrote: > > > if (my $x = frobnicate(42)) { > > say $x > > } > [...] > > if frobnicate(42) -> $x { > > say $x > > } > > which is way more elegant. Should this make it wise to ha

Re: for loop index question

2017-02-28 Thread Patrick R. Michaud
I think the canonical Perl 6 answer is: for @array.kv -> $index, $value { do something } Pm On Tue, Feb 28, 2017 at 01:20:47PM -0800, ToddAndMargo wrote: > Hi All, > > There are times when I want to know th4e index of an array > when I am in a "for @array" loop. I can do it with a > variab

Re: [perl #129829] .pick on large ranges returns binary-sparse result

2016-10-07 Thread Patrick R. Michaud
On Fri, Oct 07, 2016 at 12:18:43PM -0700, Aaron Sherman wrote: > [15:12] m: say ((2**80) ..^ (2**81)).pick.base(2) > [15:12] <+camelia> rakudo-moar 605f27: > OUTPUT«100011101100100110010001010110101101010011001␤» > > The middle part is always a large number of

Re: Startup performance on OS X

2016-10-03 Thread Patrick R. Michaud
On Mon, Oct 03, 2016 at 04:26:10PM +0200, Elizabeth Mattijsen wrote: > > On 02 Oct 2016, at 11:00, Thor Michael Støre wrote: > > Is this normal startup performance? > > https://www.promptworks.com/blog/public-keys-in-perl-6 > > I wonder what would be needed to run this in Perl 5, module wise, an

Re: Startup performance on OS X

2016-10-02 Thread Patrick R. Michaud
On Sun, Oct 02, 2016 at 11:00:38AM +0200, Thor Michael Støre wrote: > Thormicks-MacBook-Pro-3:~ thormick$ time perl6 -e "say 'foo'" > foo > > real 0m0.205s > user 0m0.150s > sys 0m0.045s > > [...] > > Foo indeed! ~200ms for this seems awfully slow to me. On another hand, my machine shows: $

Re: Best way to get a PCRE6 on the JVM?

2016-09-29 Thread Patrick R. Michaud
On Thu, Sep 29, 2016 at 01:30:29PM +0200, Joachim Durchholz wrote: > Can you tell me where the sources for the regex engine live? At the > detailed-technical-spec level, I found S05, and I can find the NQP spec, but > I don't know my way around the interpreter sources yet. The regex engine lives i

Re: Best way to get a PCRE6 on the JVM?

2016-09-28 Thread Patrick R. Michaud
A simpler approach might be to build an NQP that runs on the JVM, and find a way to call into it. (The Perl 6 regular expression engine is written in NQP.) Pm On Wed, Sep 28, 2016 at 09:21:50AM -0400, Will Coleda wrote: > To start with, there isn't a PCRE6. > > If you want, more generically, to

Re: [perl #129346] [BUG] Whatever being called on where-blocked subroutine cannot handle the sigilless values correctly

2016-09-24 Thread Patrick R. Michaud via RT
On Sat, Sep 24, 2016 at 07:37:52AM +, Lloyd Fournier wrote: > I think this is because .WHAT is a special case. It's not really a method > which is what you need to make *.method work. *.WHAT will always return > (Whatever) immediately. You're correct that .WHAT is a special case. From S12, "I

Re: [perl #129346] [BUG] Whatever being called on where-blocked subroutine cannot handle the sigilless values correctly

2016-09-24 Thread Patrick R. Michaud
On Sat, Sep 24, 2016 at 07:37:52AM +, Lloyd Fournier wrote: > I think this is because .WHAT is a special case. It's not really a method > which is what you need to make *.method work. *.WHAT will always return > (Whatever) immediately. You're correct that .WHAT is a special case. From S12, "I

Re: [perl #129271] [REGEX] Captures from interpolated variables do not capture

2016-09-14 Thread Patrick R. Michaud
On Wed, Sep 14, 2016 at 05:10:55PM -0700, Zoffix Znet wrote: > m: my $input = '(\d\d\d)'; my $m = 'a 123' ~~ /<$input>/; dd > [$m.list]; > rakudo-moar 2c95f7: OUTPUT«[]␤» > > > Expected results: output is the same, as the $input contains a capture that > should capture stuff when interpolated

Re: grammars and indentation of input

2016-09-13 Thread Patrick R. Michaud
I don't have an example handy, but I can categorically say that Perl 6 grammars are designed to support exactly this form of parsing. It's almost exactly what I did in "pynie" -- a Python implementation on top of Perl 6. The parsing was done using a Perl 6 grammar. If I remember correctly, Pynie

Re: Fwd: Re: grammars and indentation of input

2016-09-13 Thread Patrick R. Michaud
On Tue, Sep 13, 2016 at 10:35:01AM -0400, Bennett Todd wrote: > Having the minutia of the programmatic run-time state of the parse then > influence the parse itself, is at the heart of the perl5 phenomenon "only > Perl can parse perl", which I rather hope isn't going to be preserved in > perl6.

Re: [perl #129131] [RFC] Make .. a numeric operator, please (.say for ‘42’..‘51’)

2016-08-30 Thread Patrick R. Michaud
On Tue, Aug 30, 2016 at 07:00:43PM -0700, Zoffix Znet via RT wrote: > So far I think the original RFC to make .. a numeric operator is out. > There's still an issue with .. not using .succ on strings. Does anyone > know why that is the case? The templating example I presented is still > valid wi

Re: can Perl 6 bootstrap itself

2016-08-25 Thread Patrick R. Michaud
On Thu, Aug 25, 2016 at 10:37:45AM -0700, Dipesh Sharma wrote: > Dependency on perl5 for building perl6 looks like a concern. It means that > we can't have and environment with perl6, without perl5. I disagree. Just because perl5 is currently required to *build* Rakudo doesn't mean that perl5 h

Re: [perl #122346] [@LARRY] "nom regression" behavior of lexicals/invoking sub before they are defined changed

2016-08-23 Thread Patrick R. Michaud
On Tue, Aug 23, 2016 at 10:28:26AM -0700, Will Coleda via RT wrote: > > Where the expectation is that the first call to the foo will return an > > undefined value; in nom, it returns 0. > > This behavior has been in place for years now, since before Christmas. > > Tagging [@LARRY] to get a ruling

Re: [perl #128984] Feature request (wontfix?): perl -c executes BEGIN and CHECK blocks

2016-08-18 Thread Patrick R. Michaud
On Thu, Aug 18, 2016 at 10:38:57AM -0400, Brandon Allbery wrote: > On Thu, Aug 18, 2016 at 9:13 AM, Claudio > wrote: > > > Tools like vim-syntastic and atom use 'perl6-c' (the only valid linter for > > now) to report syntax errors. Because "perl6 -c" executes code (BEGIN and > > CHECK blocks as d

Re: [perl #128842] [BUG] := inconsistent semantics

2016-08-04 Thread Patrick R. Michaud
On Thu, Aug 04, 2016 at 09:54:54PM +0100, Zefram wrote: > Patrick R. Michaud wrote: > >So are you looking for...? > > No. I want a writable reference that I can pass around as a value, > store in a data structure, and so on. The Scalar object obtained by > "$a.VAR&quo

Re: [perl #128842] [BUG] := inconsistent semantics

2016-08-04 Thread Patrick R. Michaud
On Thu, Aug 04, 2016 at 09:36:18PM +0100, Zefram wrote: > Yeah. Let me try to make it clearer. In the above situation, with > a reference to $a's Scalar container in $b, I'd like to achieve what > the assignment "$a = 5" would, but by an operation using $b and not > directly mentioning $a. The r

Re: [perl #128818] [BUG] sprintf %f bogus rounding

2016-08-02 Thread Patrick R. Michaud
On Tue, Aug 02, 2016 at 07:46:20PM +0100, Zefram wrote: > > sprintf("%f", 2e0**70) > 118059162071741000.00 > > >In particular, the true value is *not* always available, > > By "true value" I meant the value represented in floating point. My apologies, I did not catch this meaning of "tru

Re: [perl #128817] [BUG] Num.perl doesn't round-trip numeric value

2016-08-02 Thread Patrick R. Michaud
On Tue, Aug 02, 2016 at 07:32:56PM +0100, Zefram wrote: > Patrick R. Michaud via RT wrote: > >I don't know that we should expect .perl or any other operation on Num > >values to be preserving more precision than that. > > I'd expect .perl to preserve whatever

Re: [perl #128820] [BUG] == on Num literals produces bogus answer

2016-08-02 Thread Patrick R. Michaud
On Tue, Aug 02, 2016 at 10:55:34AM -0700, Zefram wrote: > These literals work fine in other contexts: > > > my $a = 1180591620717411303424e0 > 1.18059162071741e+21 > > my $b = 1180591620717409992704e0 > 1.18059162071741e+21 > > $a.Int > 1180591620717411303424 > > $b.Int > 1180591620717409992704 >

Re: [perl #128818] [BUG] sprintf %f bogus rounding

2016-08-02 Thread Patrick R. Michaud
On Tue, Aug 02, 2016 at 09:56:38AM -0700, Zefram wrote: > > (1180591620717411303424.0e0).Int > 1180591620717411303424 > > sprintf("%f", 1180591620717411303424.0e0) > 118059162071741000.00 > > sprintf %f is not showing the true value of this Num, which it should. > The .Int coercion is corr

Re: Questions on using other "modules" in nqp

2016-08-01 Thread Patrick R. Michaud
My short answer would be that there's not a shortcut way in NQP to avoid the fully-qualified sub names. I'm doubtful that we want to duplicate Perl 6's import mechanism into NQP. Pm On Fri, Jul 22, 2016 at 07:48:55AM -0500, Tom Browder wrote: > ping > > On Thu, Jul 7, 2016 at 7:49 AM, Tom Browd

Re: [perl #128587] [POD] need pod-to-man translator

2016-07-12 Thread Patrick R. Michaud
On Tue, Jul 12, 2016 at 08:48:59AM -0500, Tom Browder wrote: > > If --help mentions a man page, it's probably sufficient to ship Rakudo > > with an already-translated man page, rather than shipping the translator. > >Very true--the voice of reason! > >But shouldn't all the pod6-to-X trans

Re: [perl #128587] [POD] need pod-to-man translator

2016-07-12 Thread Patrick R. Michaud
I think any pod2man translator program should be separate from Rakudo itself. If --help mentions a man page, it's probably sufficient to ship Rakudo with an already-translated man page, rather than shipping the translator. Pm On Tue, Jul 12, 2016 at 04:34:00AM -0500, Tom Browder wrote: >On M

Re: [perl #128584] [BUG] reduce subroutine returns NaN when calculating decimals with negative exponents

2016-07-09 Thread Patrick R. Michaud
On Sat, Jul 09, 2016 at 05:19:49AM -0700, Itsuki Toyota wrote: > See the following results > > $ perl6 -e 'say -1 ** -0.1' > -1 > $ perl6 -e 'say reduce * ** *, -1, (-0.1)' > NaN This is not a bug in "reduce" itself. Exponentiation has higher precedence than unary minus, so the first expression

Re: [perl #128584] [BUG] reduce subroutine returns NaN when calculating decimals with negative exponents

2016-07-09 Thread Patrick R. Michaud via RT
On Sat, Jul 09, 2016 at 05:19:49AM -0700, Itsuki Toyota wrote: > See the following results > > $ perl6 -e 'say -1 ** -0.1' > -1 > $ perl6 -e 'say reduce * ** *, -1, (-0.1)' > NaN This is not a bug in "reduce" itself. Exponentiation has higher precedence than unary minus, so the first expression

Re: capture through regex variable

2016-02-22 Thread Patrick R. Michaud
Dynamic subregexes such as <$top> are non-capturing by default. You can easily capture the result by using something like instead: $ cat xyz.p6 my $match; my $top = rx/ \( $ = [ \w* ] \) /; given "(abc)" { $match = m/^ /; } if $match { say

Re: is there a Perl 5 converter?

2016-01-21 Thread Patrick R. Michaud
On Thu, Jan 21, 2016 at 01:39:15PM -0600, Aaron Baugher wrote: > Tom Browder writes: > > > Thanks, Aaron, good explanation. But can you find a description of > > '<->' in the Perl 6 docs? > > It's mentioned here: https://doc.perl6.org/language/control#for > > And here, where it's called the "d

Re: Recalling previous commands

2016-01-01 Thread Patrick R. Michaud
While I recall that we've often discussed building command history into Rakudo's REPL directly, the workaround suggested to me was to use 'rlwrap': $ rlwrap ./perl6 Then the arrow keys work, as well as CTRL-P and other bash-like history commands. I've never used CTRL-K for history, but rlw

Re: c99 hexadecimal floating point support?

2015-12-31 Thread Patrick R. Michaud
On Thu, Dec 31, 2015 at 04:13:40PM +0900, Dan Kogai wrote: > Anyway, is there a plan to support hexadecimal floating point support? > % perl6 -e 'say 0x1.921fb54442d18p+1' > ===SORRY!=== Error while compiling -e > Malformed postfix call > at -e:1 > --> say 0x1.⏏921fb54442d18p+1 $ ./perl6 -e 's

Re: release?

2015-12-29 Thread Patrick R. Michaud
On Tue, Dec 29, 2015 at 01:57:57AM -0800, Darren Duncan wrote: > On that note, are there going to be Perl 6 versions 6.x.y where {x,y} are > integers? Will 6.0.0 be the first such one? -- Darren Duncan This was the topic of my FOSDEM talk last year, and then again at YAPC::NA. "Perl 6" is a lang

Re: [perl #126664] .roll on a Range of Num ain't random

2015-11-27 Thread Patrick R. Michaud
The standard meaning of ".roll" is to randomly select elements from a list. So I'd expect .roll on a Range to first convert the Range to a list of values and then select from those. If the intent is to select from the values 0.1, 0.2, 0.3, I'd expect the programmer to write: (0.1, 0.2, 0.3).

Re: Missing documentation

2015-10-28 Thread Patrick R. Michaud
I suspect that http://doc.perl6.org/language/5to6 should at least have be a redirect to somewhere useful, if not an index of the available 5to6 pages. Pm On Wed, Oct 28, 2015 at 09:22:55PM +0100, Kaare Rasmussen wrote: > On 10/28/2015 08:31 PM, Parrot Raiser wrote: > >This Perl 5 to 6 Translatio

Re: How to call a super class method?

2015-10-28 Thread Patrick R. Michaud
On Wed, Oct 28, 2015 at 03:31:09AM +, TS xx wrote: > > Can I call the Person's constructor (in non static context), > pass the required parameter and do more things before returning? There are two answers to this question, both of which likely deserve a few lines in doc.perl6.org/language/fa

Re: To :D or not to :D

2015-10-12 Thread Patrick R. Michaud
On Tue, Oct 13, 2015 at 12:32:01AM +0200, Mark Overmeer wrote: > Yes, that what I started realizing when I saw all the pain Perl6 goes to > ignore the existence of a real "undef" in the language. (I follow Perl6 > from a short distance since its start, read all original designs, but > this penny d

Re: To :D or not to :D

2015-10-12 Thread Patrick R. Michaud
On Mon, Oct 12, 2015 at 09:51:13PM +0200, Mark Overmeer wrote: > > method new(MyClassHere:U: *@args) { ... } > > > > in the constructor, which would be quite hostile to newbies. It's still > > not clear to me how to avoid that. > > It is also unclear to me what this means. It is a method whi

Re: Sub args: choose one of two?

2015-07-02 Thread Patrick R. Michaud
On Thu, Jul 02, 2015 at 03:21:11PM -0500, Tom Browder wrote: > Okay, a second look shows me that's not quite as bad as I first though. Another possibility is to let MAIN unpack the args for you, but then check the exclusivity directly instead of using multisubs to do it: sub MAIN(:$need, :$h

Re: Sub args: choose one of two?

2015-07-02 Thread Patrick R. Michaud
On Thu, Jul 02, 2015 at 03:22:17PM -0400, Brandon Allbery wrote: > On Thu, Jul 2, 2015 at 3:08 PM, Tom Browder wrote: > > > 1. Write the 'main' program as another subroutine and call it from > > each of the appropriate multi > > subs--aarghh! > > > > This seems like the right one to me; it also

Re: Sub args: choose one of two?

2015-06-30 Thread Patrick R. Michaud
On Sat, Jun 27, 2015 at 05:39:32PM -0500, Tom Browder wrote: > I'm trying to take advantage of the MAIN suroutine to handle most all of my > routine command line arg handling. One idiom I use a lot is for the user > to choose only one of two args, but one must be chosen. Perhaps you want that the

Re: [perl #125427] [BUG][Feature][GLR] Can't define custom flat prefix op with pipe

2015-06-16 Thread Patrick R. Michaud
On Wed, Jun 17, 2015 at 12:24:04AM -0500, Patrick R. Michaud wrote: > In Rakudo unary | is a syntactic construct that can't be overloaded. > > So, notabug. :) More directly to the comment about unary | possibly working outside of argument lists, I'm not sure we want to en

Re: [perl #125427] [BUG][Feature][GLR] Can't define custom flat prefix op with pipe

2015-06-16 Thread Patrick R. Michaud
On Tue, Jun 16, 2015 at 09:28:28PM -0700, Brent Laabs wrote: > 07:02 labster m: multi sub prefix:<|> (\a) { a.flat }; say > (|[1,2,3]).perl > 07:02 camelia rakudo-moar d6430c: OUTPUT«5===SORRY!5=== Error while > compiling /tmp/jvrQI4RBsS␤Arg-flattening | is only valid in an argument

Re: New Logo Design for perl6 modules

2015-06-11 Thread Patrick R. Michaud
Let's not forget the raptors. (Both "Veloci" and "Utah" are candidates. :) Pm On Thu, Jun 11, 2015 at 07:45:06PM -0700, Darren Duncan wrote: > Or a pumpkin for that matter, since Perl 5 is Pumpkin Perl. -- Darren Duncan > > On 2015-06-11 7:42 PM, Darren Duncan wrote: > >I was going to say that

Re: [perl #125391] Wrong order with %% $=.*

2015-06-11 Thread Patrick R. Michaud
On Thu, Jun 11, 2015 at 02:53:15PM -0700, Alex Jakimenko wrote: > say grammar Gram { regex TOP { ('XX')+ %% $=<[a..z]>* }; > }.parse('XX'); > > Output: > 「XX」 > 0 => 「XX」 > 0 => 「XX」 > delim => 「」 > 0 => 「XX」 > delim => 「」 > delim => 「」 > > The order is wrong. I'm not entirely cer

Re: [perl #125334] min(+'a', +'a').say prints Inf but should produce an error

2015-06-08 Thread Patrick R. Michaud
On Mon, Jun 08, 2015 at 06:08:33AM -0700, Will Coleda via RT wrote: > I agree that this should be throwing the same conversion error. I disagree to the extent that making min() throw the conversion error seems to go against the purpose of designing soft/lazy Failure types into Perl 6 in the first

Re: generating grammars, capturing in regex interpolation, etc.

2015-04-14 Thread Patrick R. Michaud
On Tue, Apr 14, 2015 at 08:58:27PM -0400, Nathan Gray wrote: > I've run into a snag, in that my strptime processing in Perl 5 > relies on building a string that looks like a regex with named > captures, and then interpolating that into a real regex. >[...] > my $pattern = Q/$=[hello]/; > my

Re: [perl #123800] [BUG] © doesn't copy the umask in Rakudo

2015-02-11 Thread Patrick R. Michaud
On Wed, Feb 11, 2015 at 04:21:32PM -0500, Parrot Raiser wrote: > Not replicating the original file permissions on a copy would be a > huge security hole. Anybody could copy a root-read-only file, examine > the contents, modify them, and, if they had write access to the > directory, replace it with

Re: Profiling Perl 6 code

2014-12-31 Thread Patrick R. Michaud
If you're running Rakudo on MoarVM, try the --profile option. It will create an HTML file that shows a lot of useful information, including time spent in each routine, call graphs, GC allocations, etc. Pm On Wed, Dec 31, 2014 at 09:35:33AM +0200, Gabor Szabo wrote: > The Perl 6 Maven site is a

Re: Is this a strange regex bug in my code?

2014-12-29 Thread Patrick R. Michaud
4 at 09:29:39AM +0200, Gabor Szabo wrote: > No. If I remove the leading m from the regex, then the bug is gone. > Gabor > > On Tue, Dec 30, 2014 at 9:19 AM, Patrick R. Michaud > wrote: > > > Out of curiosity, is the bug still present if you use /\.txt$/ instead of > &

Re: Is this a strange regex bug in my code?

2014-12-29 Thread Patrick R. Michaud
Out of curiosity, is the bug still present if you use /\.txt$/ instead of m/\.txt$/ ? At the moment it looks like a Rakudo bug to me, but I haven't been able to golf it further to be certain. Pm On Tue, Dec 30, 2014 at 09:11:52AM +0200, Gabor Szabo wrote: > Just to follow-up: > The problem a

Re: [perl #122892] [BUG] Scoping issue with regex using attribute in method in Rakudo

2014-10-03 Thread Patrick R. Michaud
On Fri, Oct 03, 2014 at 06:48:50AM -0700, Carl Mäsak wrote: > m: class C { has $.sep = "|"; method foo { .say for > "foo|bar".split(/$!sep/).map(~*) } }; C.new.foo > rakudo-moar da3aae: OUTPUT«foo|bar␤» > TuxCM: interesting. > * masak submits rakudobug 14:09 m: class C { has $.rx = 'bc'; meth

[perl #122882] [BUG] Symmetric set difference (^) doesn't right-associate or chain in Rakudo

2014-10-02 Thread Patrick R. Michaud via RT
Added tests in roast/S03-operators/set.t, marking ticket resolved. Pm

Re: [perl #122882] [BUG] Symmetric set difference (^) doesn't right-associate or chain in Rakudo

2014-10-01 Thread Patrick R. Michaud
On Wed, Oct 01, 2014 at 09:00:08PM -0700, Carl Mäsak wrote: > m: say (^) (^) > > It's an interesting question in itself where the error message "Too > many positionals passed; expected 2 arguments but got 3" comes from. > Does the (^) operator somehow declare itself as chaining, but then has >

Re: Moar Parrots

2014-09-09 Thread Patrick R. Michaud
On Tue, Sep 09, 2014 at 10:07:46PM +0200, Alex Becker wrote: > Hitting the download button for Perl 6 leads to this page: > http://rakudo.org/downloads/star/ > There is a set of undocumented files. For 2014.08, there is one msi file > with the Suffix moar, and one with the Suffix parrot. To avoid

Re: match's replacement name?

2014-05-23 Thread Patrick R. Michaud
On Fri, May 23, 2014 at 03:08:38PM -0400, Peter Schwenn wrote: > Still it would be more straightforward to have something like > $layn ~~ s:g/ (\W) [[RMA\.]? OpenNURBS\.]? I? On (<[2..4]>) dPoint > /$0Rhino.Geometry.Point$1d/; > and have a more perl6-built-in way of getting hold of the /replac

Re: memory leak I think.

2013-12-19 Thread Patrick R. Michaud
On Thu, Dec 19, 2013 at 11:27:32AM +0800, Richard Hainsworth wrote: > I've been running a perl6 program that runs through a loop, dumps > intermediate results and starts again with new initialisation > values. > [...] > Looking at system resources, the program chews up memory resources > continuall

  1   2   3   4   5   6   7   8   9   10   >