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 object.

You can see this with the following:

$ rakudo
To exit type 'exit' or '^D'
> say Nil
Nil
> put Nil
Use of Nil in string context
  in block  at  line 1
> say Nil.Str
Use of Nil in string context
  in block  at  line 1
> put Nil.gist
Nil

So, the difference in your example is that when the result of s/.../.../ is Nil 
(representing a failed Match), C calls .gist on Nil which produces a 
printable string, while C attempts to stringify the Nil object directly 
and that throws an error.

Pm

On Sun, May 17, 2020 at 11:59:18PM -0700, William Michels via perl6-users wrote:
> Hello,
> 
> I'm interested in knowing the differences between the return values
> when "say" is used compared to "put". My understanding is that "put"
> returns Raku's internal representation of a value held by a variable,
> while "say" is merely "put" with the .gist method called on it (a
> "human readable", often-abbreviated return value).
> 
> Below I do "S///" (non-destructive) and "s///" (destructive) text
> replacement on a three line text file in bash line [1]. In bash line
> [2], the full substituted text file is correctly returned; in bash
> line [3] using "say" only the $/ match string is returned. So far so
> good. However, a virtually-identical call in bash line [4] using "put"
> instead of "say" returns an error for the first line of the target
> text file: "Use of Nil in string context in block  at -e line 1".
> 
> [1] homedir$ cat demo1.txt
> this is a test,
> I love Unix,
> I like Linux too,
> 
> [2] homedir$ perl6 -ne 'say S/love|like/admire/;' demo1.txt
> this is a test,
> I admire Unix,
> I admire Linux too,
> 
> [3] homedir$ perl6 -ne 'say s/love|like/admire/;' demo1.txt
> Nil
> 「love」
> 「like」
> 
> [4] homedir$ perl6 -ne 'put s/love|like/admire/;' demo1.txt
> Use of Nil in string context
>   in block  at -e line 1
> 
> love
> like
> 
> [5] homedir$
> 
> I'm really trying to understand this error message:  doesn't Raku know
> that this is a text replacement operation? How can a 'Nil' be
> correctly represented when called by "say", but throw an error when
> called by "put"? If the value is absent at the Raku representational
> level and throws an error, wouldn't it be reasonable to assume that
> the same case would hold for "say"? And finally, does this "say / put"
> difference mean that some textual information will be lost from return
> values (because "say" will have to be used instead of "put" to avoid
> errorring-out)?
> 
> Any enlightenment appreciated,
> 
> TIA, Bill.


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
> |  |  * FAIL
> |  * FAIL
> * FAIL
> Nil

Notice how  is capturing the newline in "keep-alive\n"?  That 
means there's not a newline for the <.crlf> subrule that follows, and thus the 
match fails.

Try changing "rule header-value" to be a "token" instead.  That will prevent it 
from consuming any whitespace immediately following the + sequence.  
When I tried your script with header-value defined as a token, it got a lot 
farther into the match:

  $ rakudo test.raku
  TOP
  |  request-line
  |  |  method
  |  |  * MATCH "CONNECT"
  |  |  request-uri
  |  |  * MATCH "ssl.gstatic.com:443"
  |  |  http-version
  |  |  * MATCH "HTTP/1.1"
  |  |  crlf
  |  |  * MATCH "\n"
  |  * MATCH "CONNECT ssl.gstatic.com:443 HTTP/1.1\n"
  |  headers
  |  |  header
  |  |  * MATCH "Proxy-Connection"
  |  |  header-value
  |  |  * MATCH "keep-alive"
  |  |  crlf
  |  |  * MATCH "\n"
  |  * MATCH "Proxy-Connection: keep-alive\n"
  * MATCH "CONNECT ssl.gstatic.com:443 HTTP/1.1\nProxy-Connection: keep-"
  Nil


Personally, I would likely define  to be something more like

token header-value { \N+ }

which gets any sequence of non-newline characters, since some of the headers 
coming afterwards contain spaces and characters which aren't part of .

Pm


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 apparently added in 2020.01.)

Pm


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 any(;

which is indeed False.

I'm not exactly sure what sort of warning should go here, or how it'd be 
detected.  But perhaps others have ideas.  

Pm


On Sun, Jun 21, 2020 at 07:00:23PM -0700, Joseph Brenner wrote:
> I was just playing around with junctions a bit today, and I
> noticed that if you weren't religious about using parenthesis
> with them you could get quietly tripped up:
> 
> say so any() eq any();   # True   (as expected)
> say so any() eq any(); # False  (as expected)
> say so any  eq any ; # False(something's wrong)
> 
> Basically, you need the parens on that first use of any.
> 
> Is there a reason you don't at least get a warning if you don't?


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 days, any non-ASCII character in 
> any string, would have a significant negative effect on grammar parsing.  
> This was usually not that visible when trying to run a script, but the 
> time needed to compile the core setting (which already took a few minutes 
> then) rose (probably exponentially) to: well, I don't know.  

Part of this is because Parrot/ICU was using UTF-8 and/or UTF-16 to
encode non-ASCII strings.  As a result, indexing into a string often 
became a O(n) operation instead of O(1).  For short strings, no problem,
for long strings (such as the core setting) it was really painful.

We did work on some ways in Parrot/NQP to reduce the amount of string
scanning involved, such as caching certain index-points in the string, 
but it was always a bit of a hack.  Switching to a fixed-width encoding
(NFG, which MoarVM implements) was definitely the correct path to take
there.

Pm


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 that this involves creating a new scope, 
> > or a new function, or however it is that this happens.
> 
> I guess we need to update the documentation.  But the braces inside a 
> double quoted string *do* create a new scope, causing the behaviour of 
> ++$ that you have seen.

In general Raku tries to avoid special cases... so I think that braces pretty 
much _always_ introduce a new scope.  I can't think of any exceptions at the 
moment, except for *maybe* when they are used as a hash constructor.  (And 
perhaps not even there.)

Of course I could be mistaken in this... but as a general rule, in language 
design there's been an effort to keep things consistent so that we don't have 
to say things like "braces create a new scope except when used in string 
interpolation" etc.

Pm


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 
reason you don't get an error with "a.b.c".

In your example code, "a.b" returns Nil, so "a.b.c" invokes "Nil.c" which 
results in Nil and no error.

However, assigning Nil to a scalar reverts it to the type otject -- in this 
case Any.  Thus with

   my $b = a.b;

the Nil value coming from "a.b" causes $b to revert to its type object (Any).  
Then "$b.c" is the same as "(Any).c", which results in the "No such method" 
exception.

See the docs at https://docs.raku.org/type/Nil , in the section that talks 
about what happens when Nil is assigned to a container.

Hope this helps,

Pm


On Tue, Dec 01, 2020 at 08:34:31AM +0100, Konrad Bucheli via perl6-users wrote:
> Hi
> 
> I miss an error on my first invocation of `c` below:
> 
> $ raku
> Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.10.
> Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
> Built on MoarVM version 2020.10.
> 
> To exit type 'exit' or '^D'
> > class a { method b {return}}
> (a)
> > say a.b.c
> Nil
> > my $b = a.b
> (Any)
> > say $b.c
> No such method 'c' for invocant of type 'Any'
>   in block  at  line 1
> 
> >
> 
> Is there an explanation for that behavior?
> 
> Cheers
> 
> Konrad
> 


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 range operator 
(".."), then you can specify the increment this way and it may be more readable:

   > say $_ for 0.1, 0.2 ...^ 2;

Raku will auto-deduce the sequence from the values in the list on the LHS of 
the sequence operator:

   > say $_ for 0.6, 1.1 ...^ 10;

This can be of course extended -- to count from $a up to $b in steps of $x, one 
can write:

   > say $_ for $a, $a+$x ...^ $b

Note that in these examples the caret is part of the sequence operator, it's 
not a prefix to the $b argument.

Pm


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 ~~ m:g{ ( \" .*? \" ) };  # let's feed [...]

FWIW, it's also possible to quote the quotes:

  say
$str ~~ m:g{ ( '"' .*? '"' ) }

Pm


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 postfixes use the same parsing rules as qw().)

Pm


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 anywhere near far enough.   You *had better* to
> refer to it as $a or you'll get some very weird behavior, though only
> under some circumstances.

Just to clarify (because I'm not sure this is clear yet):

You get "weird" behavior if you try to use it in the $^a form in a nested 
block, because the language treats any caret variables in the nested block as 
being part of the signature definition for the nested block.

So, going to the original "if" example, writing

   { 
 if ($^a eq $^b) {
   "$^a";
 } else {
   "$^a & $^b";
 }
   }

is akin to writing

   -> $a, $b {
 if ($a eq $b) -> $a {
   "$a";
 } else -> $a, $b {
   "$a & $b";
 }
   }

Each of the nested blocks is effectively defining a local $a (and $b), and the 
error is because the else clause sends only one argument to the block where two 
are expected.

The if statement and its clauses receive the result of the comparison as 
arguments to the nested blocks, if I remember correctly.  This is why "else" 
sends only one argument to its nested block.

Hope this helps a bit,

Pm
  


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;
> 
>   say @monsters.WHAT;  # (Array)
>   say $cool_monsters.WHAT; # (Set)
> 
>   my $just_monsters = @monsters (-) $cool_monsters;
>   say $just_monsters; # Set(blob grendel wormface)
> 
> A set difference operation seems to know what to do with arrays,
> without any explicit conversion steps.  I don't think you can get
> that just from studying the type graphs

More likely, the set difference operation tries to coerce both of its
operands into Sets, and arrays know how to make themselves into a Set
(via the .Set() method inherited from List).

It's much like the way the subtraction operator (&infix:<->) tries
to coerce its operands into Numeric types, by asking the operands to
return their "Numeric" value, or the way the concatenation operator
(&infix:<~>) coerces its arguments into Stringy types.

Pm


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 digits, then:

$ raku -e "say sqrt(2).comb(/\d/)[^10].join(', ');"
1, 4, 1, 4, 2, 1, 3, 5, 6, 2

Pm


On Mon, Nov 01, 2021 at 06:55:40PM -0700, William Michels via perl6-users wrote:
> You did great for not knowing Raku!
> 
> ~$ raku -e "say sqrt(2).split(/\.|''/);"
> ( 1  4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1 )
> ~$ raku -e "say sqrt(2).split(/\.|''/).raku;"
> ("", "1", "", "4", "1", "4", "2", "1", "3", "5", "6", "2", "3", "7", "3",
> "0", "9", "5", "1", "").Seq
> ~$ raku -e "say sqrt(2).split(/\.|''/, :skip-empty);"
> (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)
> ~$ raku -e "say sqrt(2).split(/\.|''/, :skip-empty).join(', ');"
> 1, 4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 1
> 
> I moved the sqrt(2) call to the head of the method chain, then visualized
> elements using the `.raku` method (`.perl` works also, but don't tell
> anyone). You can see an empty element at the beginning/end, as well as
> where the decimal point used to reside. Including :skip-empty in your
> `.split` call sets it to True, removing empty elements.
> 
> For Mac/Linux people (swapped single/double quotes):
> 
> ~$ raku -e 'say sqrt(2).split(/\.|""/);'
> ( 1  4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1 )
> ~$ raku -e 'say sqrt(2).split(/\.|""/).raku;'
> ("", "1", "", "4", "1", "4", "2", "1", "3", "5", "6", "2", "3", "7", "3",
> "0", "9", "5", "1", "").Seq
> ~$ raku -e 'say sqrt(2).split(/\.|""/, :skip-empty);'
> (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)
> ~$ raku -e 'say sqrt(2).split(/\.|""/, :skip-empty).join(", ");'
> 1, 4, 1, 4, 2, 1, 3, 5, 6, 2, 3, 7, 3, 0, 9, 5, 1
> 
> HTH, Bill.
> 
> On Sun, Oct 31, 2021 at 5:51 AM sisyphus  wrote:
> >
> >
> >
> > On Sun, Oct 31, 2021 at 10:10 PM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
> >>
> >> On 10/31/21 01:43, Shlomi Fish wrote:
> >>
> >> >
> >> >> ("" ~ sqrt(2)).comb().grep(* ne ".").map(+*)
> >> > (1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1)
> >>
> >> Cool!
> >>
> >> my Int @x = ("" ~ sqrt(2)).comb().grep(* ne ".").map(+*)
> >> [1 4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1]
> >>
> >> Is there a way to set how many digits I get?
> >
> >
> > In perl we can do:
> > C:\>perl -e "@x = split(/\.|/, sqrt(2)); print for @x";
> > 14142135623731
> > C:\>perl -e "@x = split(/\.|/, sprintf('%.7g', sqrt(2))); print for @x";
> > 1414214
> > C:\>perl -e "@x = split(/\.|/, sprintf('%.8g', sqrt(2))); print for @x";
> > 14142136
> >
> > But the same split() expression is unacceptable to Raku.
> > Closest I could get with that approach:
> >
> > C:\>raku -e "say split(/\.|''/, sqrt 2);"
> > ( 1  4 1 4 2 1 3 5 6 2 3 7 3 0 9 5 1 )
> >
> > C:\_32>raku -e "say split(/\.|''/, sprintf('%.5g', sqrt 2));"
> > ( 1  4 1 4 2 )
> >
> > It's that additional space between the first 2 digits that has me beat.
> > (I don't know raku at all.)
> >
> > Cheers,
> > Rob
> >
> >


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 prior 
to those digits is left alone.

On Mon, Apr 29, 2024 at 05:45:49PM -0700, ToddAndMargo via perl6-users wrote:
> On 4/29/24 17:42, ToddAndMargo via perl6-users wrote:
> > Hi All,
> > 
> > I thought I understood ^ and ? used in a regex'es,
> > but I don't.
> > 
> > ^ means from the beginning and ? from the end.

I think you mean "$" here instead of "?".

Pm


Re: support for editing and history in the REPL?

2012-06-30 Thread Patrick R. Michaud
On Sat, Jun 30, 2012 at 06:39:55PM +0300, Gabor Szabo wrote:
> hi,
> 
> what do I need to install or enable in order to get a better REPL?
> 
> Things like history with up and down arrow and editing capabilities?

In Ubuntu (12.04), this requires the libreadline6-dev library to be 
installed at the time Parrot is built.  It's likely something similar
for other operating systems.

Pm


Re: support for editing and history in the REPL?

2012-06-30 Thread Patrick R. Michaud
On Sat, Jun 30, 2012 at 07:21:10PM +0300, Gabor Szabo wrote:
> On Sat, Jun 30, 2012 at 7:16 PM, Patrick R. Michaud  
> wrote:
> > On Sat, Jun 30, 2012 at 06:39:55PM +0300, Gabor Szabo wrote:
> 
> Is there a list of recommended package to install before building Parrot?

The Rakudo Star distribution lists recommended packages in its README
(https://github.com/rakudo/star/blob/master/skel/README ).

I'll move this information over to the Rakudo compiler README as well.

Thanks,

Pm


Re: IO stat exception when using :l

2012-07-05 Thread Patrick R. Michaud
On Thu, Jul 05, 2012 at 05:34:43PM +0300, Gabor Szabo wrote:
> use v6;
> my $f = "a".IO;
> if $f ~~ :r {
>say 'file readable';
> }
> if $f ~~ :l {
>  say 'symlink';
> }
> 
> the readability and most other test fail and return some undef, but
> checking for :l (symlink) throws an exception if the thing does not exist
> 
> stat failed: No such file or directory
>   in method l at src/gen/CORE.setting:7042
>   in method ACCEPTS at src/gen/CORE.setting:5958
>   in block  at t.pl:7
> 
> Is that on purpose?

Looks like a bug to me; forwarding this message to rakudo...@perl.org 
to create a ticket for it.

Thanks!

Pm


Re: IO.s size how?

2012-07-05 Thread Patrick R. Michaud
On Thu, Jul 05, 2012 at 05:51:09PM +0300, Gabor Szabo wrote:
> I can write either
> $path.IO ~~ :e
> or
> $path.IO.e
> 
> to check if a $path exists. Is either of those recommended?
> 
> How can I check for size? Based on my understanding of src/core/IO.pm
> I'd think it is
> $path.IO.s
> but that only returns True/False for a file that exists/or not.
> Is this a bug or I don't understand it?

Actually, Rakudo was returning true if the file existed and if
its filesize was greater than zero.

Either way, it's a bug, now fixed in 58d9852.  IO.s now returns 
the size (in bytes) of the corresponding file.

Thanks!

Pm


Re: File content is not written if close not called

2012-07-12 Thread Patrick R. Michaud
On Thu, Jul 12, 2012 at 05:36:58PM +0300, Gabor Szabo wrote:
> The following script leaves and epty 'data.txt' behind.
> Only if I call $fh.close is the file contents saved.
> 
> Is this a feature?
> 
> use v6;
> 
> my $fh = open 'data.txt', :w;
> $fh.print("hello\n");

While Rakudo and Parrot _should_ be closing the file upon
program exit, it's still a good idea to close filehandles
explicitly.  Since the GC doesn't have reference countfing, 
it's not always the case that filehandles are automatically
closed as soon as the last reference is broken, thus you
really want to close the filehandle explicitly.

It might be good for Rakudo and/or Parrot to have an option
to issue a warning whenever a open filehandle is closed due to
garbage collection, though.

Pm


Rakudo Star 2012.07 released

2012-07-28 Thread Patrick R. Michaud
On behalf of the Rakudo and Perl 6 development teams, I'm happy to
announce the July 2012 release of "Rakudo Star", a useful and
usable distribution of Perl 6.  The tarball for the July 2012
release is available from .

In the Perl 6 world, we make a distinction between the language 
("Perl 6") and specific implementations of the language such as
"Rakudo Perl".  This Star release includes release 2012.07 [0] of the
Rakudo Perl 6 compiler [1], version 4.6 of the Parrot Virtual
Machine [2], and various modules, documentation, and other
resources collected from the Perl 6 community.

Some of the new features added to this release include:

* Built-in metaobjects (e.g. Metamodel::ClassHOW) now inherit from Any

* &open now supports the :enc/:encoding option

* anonymous subset types (e.g., 'subset :: of Int where { $_ > 0 }')

* Rakudo Star now ships with the Template::Mojo module

This release also contains a range of bug fixes, improvements to error
reporting and better failure modes. More exceptions are thrown as typed
exceptions, and more meta-model errors have been fixed to properly
report line numbers.

Starting with this release, we will also identify changes to the
implementation or specification that can cause breakages in existing
Perl 6 code.  The following features have been deprecated or modified
due to changes in the Perl 6 specification, and are being removed
or changed as follows:

* IO::File and IO::Dir will go away, and &dir now returns values of type
  IO::Path (which is currently the superclass of IO::File and IO::Dir).
  The return values of &dir will still stringify to the base name of the
  returned file and directory names, and you can call .path on them to
  obtain the full path.

* Leading whitespace in rules and under :sigspace will no longer be
  converted to <.ws> .  For existing regexes that expect this conversion,
  add a  in front of leading whitespace to make it meta again.
  Scheduled for the 2012.08 release.

* The ?-quantifier on captures in regexes currently binds the capture
  slot to a List containing either zero or one Match objects; i.e., it
  is equivalent to "** 0..1".  In the future, the ?-quantifier will
  bind the slot directly to a captured Match or to Nil.  Existing code
  can manage the transition by changing existing ?-quantifiers to
  use "** 0..1", which will continue to return a List of matches.
  Scheduled for the 2012.08 release, but may end up in 2012.09 .

* The method Str.bytes will be removed. To get the number of codepoints
  in a string, use .codes instead. To get the number of bytes in a
  given encoding, use $str.encode($encoding).bytes .
  Scheduled for the 2012.08 release.

* The method Str.lcfirst will be removed without replacement.
  Scheduled for the 2012.08 release.

* The method Str.ucfirst will eventually be removed, and replaced by
  Str.tc.
  No schedule yet, depends on having tc implemented first.

* 'abs' is currently a prefix operator, and will be changed to a normal
  subroutine.
  Scheduled for the 2012.08 release.

* The integer argument to IO::Socket.recv will be interpreted as number of
  characters/codepoints.
  Scheduled for the 2012.08 release.

There are some key features of Perl 6 that Rakudo Star does not
yet handle appropriately, although they will appear in upcoming
releases.  Some of the not-quite-there features include:

  * macros
  * threads and concurrency
  * Unicode strings at levels other than codepoints
  * interactive readline that understands Unicode
  * non-blocking I/O
  * much of Synopsis 9

There is a new online resource at http://perl6.org/compilers/features 
that lists the known implemented and missing features of Rakudo Star
2012.07 and other Perl 6 implementations.

In many places we've tried to make Rakudo smart enough to inform the
programmer that a given feature isn't implemented, but there are
many that we've missed.  Bug reports about missing and broken
features are welcomed at .

See http://perl6.org/ for links to much more information about 
Perl 6, including documentation, example code, tutorials, reference
materials, specification documents, and other supporting resources.
An updated draft of a Perl 6 book is available as 
 in the release tarball.

The development team thanks all of the contributors and sponsors
for making Rakudo Star possible.  If you would like to contribute,
see , ask on the perl6-compi...@perl.org
mailing list, or join us on IRC #perl6 on freenode.

[0] https://github.com/rakudo/rakudo/blob/nom/docs/announce/2012.07
[1] http://github.com/rakudo/rakudo
[2] http://parrot.org/


Rakudo Star 2012.08 released

2012-08-31 Thread Patrick R. Michaud
On behalf of the Rakudo and Perl 6 development teams, I'm happy to
announce the August 2012 release of "Rakudo Star", a useful and
usable distribution of Perl 6.  The tarball for the August 2012
release is available from .
A Windows .MSI version of Rakudo Star is also being made available
in the downloads area.

In the Perl 6 world, we make a distinction between the language 
("Perl 6") and specific implementations of the language such as
"Rakudo Perl".  This Star release includes release 2012.08 [0] of the
Rakudo Perl 6 compiler [1], version 4.6 of the Parrot Virtual
Machine [2], and various modules, documentation, and other
resources collected from the Perl 6 community.

Some of the new features added to this release include:

* Rakudo Star now includes a Perl 6 debugger!  The debugger allows
  single-stepping, setting breakpoints, variable inspection/modification, 
  regex debugging, and more!  Enter "perl6-debug " to run 
  a script in debugging mode.  Enter "help" from a debug prompt to
  see the available commands.

* Memory usage of the build stage has been reduced by 35% - 40%.  This
  makes it possible to build and compile Rakudo Star on machines with
  less memory (although 1.2GB may still be needed for some 64-bit
  environments).

* Variables prefixed by | or \ in signatures are now sigilless, per updates
  to the Perl 6 specification.

* Circularities in module loading are now detected.

* An improved inliner, allowing a wider range of routines to be inlined.

* Str.bytes and lcfirst have been removed.  The tclc builtin
  has been added.

* 'abs' is now a normal subroutine instead of a prefix operator.

* IO::File and IO::Dir have been removed.

* The integer argument to IO::Socket.recv is now interpreted as 
  a number of characters/codepoints.

This release also contains a range of bug fixes, improvements to error
reporting and better failure modes. More exceptions are thrown as typed
exceptions, and more meta-model errors have been fixed to properly
report line numbers.

The following features have been deprecated or modified from previous
releases due to changes in the Perl 6 specification, and are being removed
or changed as follows:

* Parameters preceded by a | or \ can no longer have a sigil.

* IO::Path.dir (which returns the directory part of the path) has been
  renamed to IO::Path.directory.  IO::Path.dir will be removed or
  re-purposed.

* The Str.ucfirst builtin is deprecated; it will be replaced by Str.tc.

* The (experimental) LAZY statement prefix will soon be removed.

* Leading whitespace in rules and under :sigspace will no longer be
  converted to <.ws> .  For existing regexes that expect this conversion,
  add a  in front of leading whitespace to make it meta again.

* The ?-quantifier on captures in regexes currently binds the capture
  slot to a List containing either zero or one Match objects; i.e., it
  is equivalent to "** 0..1".  In the future, the ?-quantifier will
  bind the slot directly to a captured Match or to Nil.  Existing code
  can manage the transition by changing existing ?-quantifiers to
  use "** 0..1", which will continue to return a List of matches.

There are some key features of Perl 6 that Rakudo Star does not
yet handle appropriately, although they will appear in upcoming
releases.  Some of the not-quite-there features include:

  * macros
  * threads and concurrency
  * Unicode strings at levels other than codepoints
  * interactive readline that understands Unicode
  * non-blocking I/O
  * much of Synopsis 9

There is an online resource at http://perl6.org/compilers/features 
that lists the known implemented and missing features of Rakudo Star
2012.08 and other Perl 6 implementations.

In many places we've tried to make Rakudo smart enough to inform the
programmer that a given feature isn't implemented, but there are
many that we've missed.  Bug reports about missing and broken
features are welcomed at .

See http://perl6.org/ for links to much more information about 
Perl 6, including documentation, example code, tutorials, reference
materials, specification documents, and other supporting resources.
A draft of a Perl 6 book is available as  
in the release tarball.

The development team thanks all of the contributors and sponsors
for making Rakudo Star possible.  If you would like to contribute,
see , ask on the perl6-compi...@perl.org
mailing list, or join us on IRC #perl6 on freenode.

[0] https://github.com/rakudo/rakudo/blob/nom/docs/announce/2012.08
[1] http://github.com/rakudo/rakudo
[2] http://parrot.org/


Rakudo Star 2012.09 released

2012-09-30 Thread Patrick R. Michaud
On behalf of the Rakudo and Perl 6 development teams, I'm happy to
announce the September 2012 release of "Rakudo Star", a useful and
usable distribution of Perl 6.  The tarball for the September 2012
release is available from .
A Windows .MSI version of Rakudo star will usually appear in
the downloads area shortly after the tarball release.

In the Perl 6 world, we make a distinction between the language 
("Perl 6") and specific implementations of the language such as
"Rakudo Perl".  This Star release includes release 2012.09.1 [0] of the
Rakudo Perl 6 compiler [1], version 4.6.0 of the Parrot Virtual
Machine [2], and various modules, documentation, and other
resources collected from the Perl 6 community.

Some of the new features added to this release include:

* Basic macro support!

* Support for Perl 5 (m:P5/.../) regex syntax!

* Indirect type names in routine and type declarations are supported.

* We support the "is export" trait on constant declarations.

* The "is hidden" and base traits are supported.

* Str.wordcase, is-prime, and expmod are implemented.

* Compilation is slightly faster than before.

* Tie-breaking with constraints selects the first matching
  constraint rather than demanding mutual exclusion.

* Smart matching against Signature literals, and binding to Signatures
  in declarators.

This release also contains a range of bug fixes, improvements to error
reporting and better failure modes. More exceptions are thrown as typed
exceptions, and more meta-model errors have been fixed to properly
report line numbers.

The following features have been deprecated or modified from previous
releases due to changes in the Perl 6 specification, and are being removed
or changed as follows:

* Iterable is now a role instead of a class, and no longer inherits 
  from Cool.

* Parameters preceded by a | or \ can no longer have a sigil.

* IO::Path.dir (which returns the directory part of the path) has been
  renamed to IO::Path.directory.  IO::Path.dir will be removed or
  re-purposed.

* The Str.ucfirst builtin is deprecated; it will be replaced by Str.tc.

* The (experimental) LAZY statement prefix will soon be removed.

* Leading whitespace in rules and under :sigspace will no longer be
  converted to <.ws> .  For existing regexes that expect this conversion,
  add a  in front of leading whitespace to make it meta again.

* The ?-quantifier on captures in regexes currently binds the capture
  slot to a List containing either zero or one Match objects; i.e., it
  is equivalent to "** 0..1".  In the future, the ?-quantifier will
  bind the slot directly to a captured Match or to Nil.  Existing code
  can manage the transition by changing existing ?-quantifiers to
  use "** 0..1", which will continue to return a List of matches.

There are some key features of Perl 6 that Rakudo Star does not
yet handle appropriately, although they will appear in upcoming
releases.  Some of the not-quite-there features include:

  * advanced macros
  * threads and concurrency
  * Unicode strings at levels other than codepoints
  * interactive readline that understands Unicode
  * non-blocking I/O
  * much of Synopsis 9

There is an online resource at http://perl6.org/compilers/features 
that lists the known implemented and missing features of Rakudo 
and other Perl 6 implementations.

In many places we've tried to make Rakudo smart enough to inform the
programmer that a given feature isn't implemented, but there are
many that we've missed.  Bug reports about missing and broken
features are welcomed at .

See http://perl6.org/ for links to much more information about 
Perl 6, including documentation, example code, tutorials, reference
materials, specification documents, and other supporting resources.
A draft of a Perl 6 book is available as  
in the release tarball.

The development team thanks all of the contributors and sponsors
for making Rakudo Star possible.  If you would like to contribute,
see , ask on the perl6-compi...@perl.org
mailing list, or join us on IRC #perl6 on freenode.

[0] https://github.com/rakudo/rakudo/blob/nom/docs/announce/2012.09
[1] http://github.com/rakudo/rakudo
[2] http://parrot.org/


Re: implementing every(N)

2013-01-08 Thread Patrick R. Michaud
On Tue, Jan 08, 2013 at 12:14:22PM -0500, Ted Zlatanov wrote:
> On Mon, 7 Jan 2013 17:51:52 +0100 Carl Mäsak  wrote: 
> 
> CM> Ted (>):
> >> Are state variables available now, or is the every(N) functionality
> >> possible in some other way now?
> 
> CM> Why not try it by writing a small program? :)
> CM> $ perl6 -e 'sub foo { state $s = 0; say $s++ }; foo; foo; foo'
>
> Since I'm writing a module, I didn't think a one-liner was sufficient
> proof that state variables are reliable.  Sorry I didn't make that
> clear.  [...]

Also, if the state variables currently behave as you expect, and we
want to insure their reliability for the future, add a spectest to 
the "roast" suite.  This way we'll also quickly discover if other 
Perl 6 implementations differ on this point.  :-) 

Thanks!

Pm


Re: Packaging Perl 6 (or rather, Rakudo Star)

2013-03-05 Thread Patrick R. Michaud
On Tue, Mar 05, 2013 at 11:13:51AM +0100, Rob Hoelz wrote:
> I already have my own package for Arch Linux for Rakudo Star, and I keep
> the OS X homebrew package up-to-date as well.  I'd like to create an RPM
> spec file and a DEB spec file as well.  I have two questions:
> 
> 1) Do these spec files belong in the Rakudo Star repository?

I have no problem with maintaining spec files in any of the
Rakudo-related repos (NQP, Rakudo, Star).

> 2) Which makes more sense: having a Rakudo Star package that depends on
> a separate Rakudo package (so Rakudo Star would only consist of modules
> and applications), or having a Rakudo Star package that conflicts with a
> separate Rakudo package (so users may install one or the other)?  [...]

I suspect to ever be considered for official inclusion in Debian/Ubuntu
distros, you'd have to have the first option (separate compiler and
module packages).  And moreso:  they likely prefer to see each module
as its own package, rather than a single package containing a complete
collection of modules.  (I think module collections in the .deb world 
tend to be managed as packages with dependencies, as opposed to 
all-in-one packages.)

It may also be worth noting/reminding that Rakudo Star has never been
intended to be the "only" or even "primary" module collection, it's just
one of the first.  It could make good sense to come up with a new
P6 distribution that is better tailored to the needs of OS distros.

Pm


Re: Packaging Perl 6 (or rather, Rakudo Star)

2013-03-05 Thread Patrick R. Michaud
On Tue, Mar 05, 2013 at 12:02:01PM +0100, Rob Hoelz wrote:
> On 3/5/13 11:44 AM, Patrick R. Michaud wrote:
> > It may also be worth noting/reminding that Rakudo Star has never been
> > intended to be the "only" or even "primary" module collection, it's just
> > one of the first.  It could make good sense to come up with a new
> > P6 distribution that is better tailored to the needs of OS distros.
> 
> Another good point; should we hold off on making packages for Rakudo
> Star until something more appropriate comes along, or should we go
> ahead and make some packages?  I would favor the latter, myself.

Same here.  I think "something more appropriate" is much more likely to
arrive with the "go ahead and make" approach than the "hold off" one.  :)

Pm


Re: prove that the meaning of live is math

2013-05-26 Thread Patrick R. Michaud
On Sun, May 26, 2013 at 09:54:21AM -0500, Hao Wu wrote:
> However, why 42? any relation to meaning of life? It seems I miss
> something. Thanks.

42 is the "Answer to the Ultimate Question of Life, the Universe, 
and Everything", which is sometimes shortened to be "meaning of life".

See 
https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy
 .

Pm


Rakudo Star 2013.05 released

2013-05-30 Thread Patrick R. Michaud
## A useful, usable, "early adopter" distribution of Perl 6

On behalf of the Rakudo and Perl 6 development teams, I'm happy to
announce the May 2013 release of "Rakudo Star", a useful and usable
distribution of Perl 6. The tarball and Windows .MSI for the May 2013 
release are available from . 

In the Perl 6 world, we make a distinction between the language
("Perl 6") and specific implementations of the language such as
"Rakudo Perl".  This Star release includes [release 2013.05] of the
[Rakudo Perl 6 compiler], version 5.2.0 of the [Parrot Virtual
Machine], plus various modules, documentation, and other resources
collected from the Perl 6 community.

[release 2013.05]:
https://github.com/rakudo/rakudo/blob/nom/docs/announce/2013.05.md
[Rakudo Perl 6 compiler]: http://github.com/rakudo/rakudo
[Parrot Virtual Machine]: http://parrot.org

Some of the new features added to this release include:

* The ?-quantifier on regex captures now returns a single Match object 
  (formerly returned an array).  Use `** 0..1` to get the old behavior.
* Failed matches return Nil instead of a false Match object.
* Rakudo warns when pure expressions are used in sink context
* .substr(...) now correctly accepts whatever-star closures
* Implemented shellwords postcircumfix (%h<< $x 'foo bar' >>)
* Defining operators spelled like the empty string is now illegal
* Array interpolations now properly do LTM
* Autothread "none" and "all" junctions before "any" and "one"
* Helpful error if you write "else if"/"elif" instead of "elsif"
* Throw exception if a Range is used as a Range endpoint
* Corrected argument order in IO.seek
* wrap low level VM objects in ForeignCode, allowing perl6 OO calls on them
* for loops are eager again
* add link and symlink to IO
* add Capture.Bool()
* improvements to DUMP()
* various optimizations in the optimizer and the runtime
* smartmatch against list now supports Whatever wildcards
* IO::Spec, a port of Perl 5's File::Spec
* regex special characters can be used as delimiters
* allow slice with :exists adverb on hashes
* added 125 extra opening/closing bracket-pairs

This release also contains a range of bug fixes, improvements to error
reporting and better failure modes.

The following features have been deprecated or modified from previous
releases due to changes in the Perl 6 specification, and are planned
to be removed or changed as follows:

  * `postcircumfix:<[ ]>` and `postcircumfix:<{ }>` will become
multi-subs rather than multi-methods. Both at_pos and at_key will
remain methods.

  * Unary hyper ops currently descend into nested arrays and hashes.
This will change to make them equivalent to a one-level map.

  * The Str.ucfirst builtin is deprecated; it will be replaced by
Str.tc.

  * Leading whitespace in rules and under :sigspace will no longer be
converted to `<.ws>`.  For existing regexes that expect this
conversion, add a `` in front of leading whitespace to make it
meta again.

  * The result of failed matches will be Nil instead of a Match
object returning boolean False.

There are some key features of Perl 6 that Rakudo Star does not yet
handle appropriately, although they will appear in upcoming releases.
Some of the not-quite-there features include:

  * advanced macros
  * threads and concurrency
  * Unicode strings at levels other than codepoints
  * interactive readline that understands Unicode
  * non-blocking I/O
  * much of Synopsis 9

There is an online resource at 
that lists the known implemented and missing features of Rakudo and
other Perl 6 implementations.

In many places we've tried to make Rakudo smart enough to inform the
programmer that a given feature isn't implemented, but there are many
that we've missed.  Bug reports about missing and broken features are
welcomed at .

See  for links to much more information about
Perl 6, including documentation, example code, tutorials, reference
materials, specification documents, and other supporting resources.  A
draft of a Perl 6 book is available as docs/UsingPerl6-draft.pdf in
the release tarball.

The development team thanks all of the contributors and sponsors for
making Rakudo Star possible.  If you would like to contribute, see
, ask on the 
mailing list, or join us on IRC \#perl6 on freenode.



Re: Rakudo Star 2013.05 released

2013-05-30 Thread Patrick R. Michaud
On Thu, May 30, 2013 at 11:08:13PM -0500, Patrick R. Michaud wrote:
> This Star release includes [release 2013.05] of the
> [Rakudo Perl 6 compiler], version 5.2.0 of the [Parrot Virtual
> Machine] ...

Oops.  The 2013.05 release actually contains Parrot 5.3.0.

Sorry about the typo.

Pm


Re: as perl6 has no $/ ...

2013-09-23 Thread Patrick R. Michaud
On Tue, Sep 24, 2013 at 02:14:50AM +0200, Marc Chantreux wrote:
> Come on, Perl6 people! did i miss something that takes carre of separators? 
> it would be nice to have something like:

I think it's currently specced in S32 as :nl("\n").  
See http://perlcabal.org/syn/S32/IO.html#open and
http://perlcabal.org/syn/S32/IO.html#input-line-separator .  
It may be NYI in Rakudo Perl 6 as yet.

Pm


Re: Stickers of Parrot and Perl 6 for GSoC

2013-10-07 Thread Patrick R. Michaud
   https://github.com/perl6/mu/blob/master/misc/camelia.svg
   https://github.com/perl6/mu/blob/master/misc/camelia.odg

I have a .ai of the Parrot head logo if you need it and can
send it to you.

Pm


On Mon, Oct 07, 2013 at 06:32:57PM -0500, Bruce Gray wrote:
> At the upcoming GSoC Mentor Summit, they will have a sticker exchange table.
> I would like to take Parrot and Perl 6 stickers for the exchange.
> 
> 1.Does anyone already have a supply of stickers, or already have a proof 
> on file with a print shop?
> 
> 2.Who has the original artwork for the Parrot and Camelia logos?
>   I would like to generate higher resolution images from the vector 
> originals for the print shop.
>   
> http://www.parrot.org/sites/www.parrot.org/files/parrotify_logo.png
>   http://perl6.org/camelia-logo.png
>   ( 
> https://raw.github.com/perl6/mu/master/misc/camelia.txt )
> 
> 3."Parrot speaks your language" is the obvious slogan to use for Parrot; 
> it is already in the logo.
>   Any recommendations on a slogan for the Perl 6 stickers? Just the text 
> "Perl 6" is my default.
> 
> -- 
> Thank you,
> Bruce Gray (Util of PerlMonks)
> 


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 /replacement/ and
> the count.

If it's :g, then wouldn't it be "replacement*s*"?

The real question to me is whether this is a common enough use case to
warrant the overhead of saving the replacement string(s) for every
s// , or if doing it via closure is sufficient (if a little ugly, but
IMO it's okay for rare to be a little ugly if it means common remains
fast(er) :).

Pm


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 the "undocumented files" problem... if someone will create a README 
for that directory, I'll make sure it gets installed and configured into that 
directory's page.

> So, if I just want to have a look at Perl 6 and how it behaves on Windows,
> which one should I use?

I suspect either will work fine; I'd likely try the "-moar" one myself.

Pm


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 appears in
> https://github.com/szabgab/Perl6-Maven/commit/4346c96d63e97def55e789bbeebdbdaebe8b0b33
> 
> After that I have replaced the regex match with
> 
> if substr($tmpl, *-4) ne '.txt' {
> 
> that works correctly, but I'd still like to understand if the bug was in my
> code, or if this is some Rakudo issue?
> 
> Gabor
> 
> 
> On Tue, Dec 30, 2014 at 8:57 AM, Gabor Szabo  wrote:
> 
> > I am puzzled by this.
> >
> > I have code like this:
> >
> > my @files = dir("$.source_dir").map({ $_.basename });
> >
> > for @files -> $tmpl {
> >
> > if $tmpl !~~ m/\.txt$/ {
> >
> > debug("Skipping '$tmpl' it does not end with .txt");
> >
> > next;
> >
> > }
> >
> > debug("Source file $tmpl");
> >
> > }
> >
> > and sometimes(!) it skips when it encounters a file called   'perl6-zip.txt'
> > or a file called 'perl6-write-file.txt'
> >
> > More specifically when I ran the above code (part of
> > https://github.com/szabgab/Perl6-Maven )
> >
> > on https://github.com/szabgab/perl6maven.com on this commit:
> > https://github.com/szabgab/perl6maven.com/commit/672ca19f8cc0cf893568f93c4c1488c0cd777f7c
> >   everything worked fine, but when I ran the same code on the next commit (
> > https://github.com/szabgab/perl6maven.com/commit/75e188288638dea03a0b3329b249f3685859e701
> > ) then suddenly it started to skip those two files.
> >
> >
> >


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

2014-12-29 Thread Patrick R. Michaud
I suspect it may be some weirdness with the way that $_ is being handled in 
smartmatching, then.

I think there's a slight difference between

$tmpl ~~ /regex/

and

$tmpl ~~ m/regex/

The first one does the equivalent of /regex/.ACCEPTS($tmpl), which ends up 
matching $tmpl directly against the regex and returning the resulting Match 
object.

The second one temporarily assigns $tmpl into $_, then m/regex/ does an 
immediate match against underscore to produce a Match object, which then has 
.ACCEPTS($tmpl) called on it (which returns the Match object).

I don't know exactly what is happening when !~~ is used with m/.../ -- i.e., 
when $_ is being assigned, what is happening to the Match object, and where 
negation is taking place.  It would be interesting to know if the following 
fails for you also:

   if not $tmpl ~~ m/\.txt$/ { ... }

Pm


On Tue, Dec 30, 2014 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
> > 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 appears in
> > >
> > https://github.com/szabgab/Perl6-Maven/commit/4346c96d63e97def55e789bbeebdbdaebe8b0b33
> > >
> > > After that I have replaced the regex match with
> > >
> > > if substr($tmpl, *-4) ne '.txt' {
> > >
> > > that works correctly, but I'd still like to understand if the bug was in
> > my
> > > code, or if this is some Rakudo issue?
> > >
> > > Gabor
> > >
> > >
> >


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 static site generated by some Perl 6 code.
> Currently it takes about 8 minutes to regenerate the 270 pages of the site
> which is quite frustrating.
> 
> Is there already a tool I could use to profile my code to see which part
> takes the longest time
> so I can focus my optimization efforts in the most problematic area?
> 
> regards
>Gabor


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 $string = Q/hello/;
>[...]

Just an idea: instead of building strings to be interpolated into 
a regex, could you just build regexes directly?

my $pattern = rx/$=[hello]/;
my $match = "hello" ~~ /  /;

The resulting string is captured into $match;
The second statement can also be written as:

# captures into $match
my $match = "hello" ~~ / $=$pattern /;
   
# captures into $match[0]
my $match = "hello" ~~ / $<0>=$pattern /;   
 
Hope this is useful, or at least illustrative.

> Of course, there may be a better way, since regex interpolation
> seems frowned upon in Perl 6.

I think it's more that we treat regexes as first class components (actually
closures)...  rather than EVALing strings with metacharacters, we just 
build regex expressions and interpolate them directly.

Pm


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 named arguments are required rather than
optional, via the exclamation point.  Thus:


multi sub MAIN(:$need!) { say "need"; }

multi sub MAIN(:$hope!) { say "hope"; }


If passed with either option, it executes the corresponding multi candidate.
If neither or both options are passed, it produces a usage message:


pmichaud@kiwi:~/p6/rakudo$ ./perl6 x.p6
Usage:
  x.p6 --need= 
  x.p6 --hope= 


Pm


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 makes it easier to provide
> similar functionality as a library.

This is the approach I would take, yes.

Pm


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, :$hope) {
   unless $need.defined xor $hope.defined {
   say "Usage: Exactly one of --need or --hope required";
   exit 1;
   }
   # rest of MAIN goes here
   }


Or use a one() junction, which reads quite nicely:

   sub MAIN(:$need, :$hope) {
   unless one( $need.defined, $hope.defined ) {
   say "Usage: Exactly one of --need or --hope required";
   exit 1;
   }
   # rest of MAIN goes here
   }


Pm


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/faq.  Lloyd alludes to both
answers in his replies to the original post.

1.  The typical answer to this question is to use "callwith",
"callsame", "nextwith", or "nextsame".

2.  Constructors already have some special support for building 
the superclass portions of an object -- see the BUILD submethod
described in Synopsis 12.

Pm


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 Translation guide http://doc.perl6.org/language/5to6
> >is mentioned in several places, but returns a 404.  Is it obsolete, or
> >just misplaced?
> This one you're looking for?
> http://doc.perl6.org/language/5to6-nutshell.html


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 language, not an implementation of that language.  Think of "Perl 
6" as being like "C", "C++", "Javascript", etc., where the language is separate 
from the (many) implementations of that language.

There are two key points to make:

1.  Language specification should follow implementations, not precede them.  
This has been found to be true for many programming languages, and it's the way 
things work in the Internet RFC/STD process.  An update to a language spec 
recognizes and ratifies the features that have been largely agreed upon by 
implementations and users, as opposed to prescribing what the next version of 
the language ought to look like.  First is rough consensus, then running code, 
and *then* formalization into a specification.

So, if language specification follows implementation, it's not possible for 
Rakudo or other implementations to use language version numbers as their 
primary versioning scheme.  To take an example from the C language:  My gcc 
compiler says it's version 5.2.1, but there's not a version "5.2.1" of the C 
Programming Language.  Similarly, one doesn't speak of the "C89", "C99", or 
"C11" release of GCC.

2.  It doesn't make a lot of sense to think of major/minor version numbers such 
as 6.x.y when discussing a language specification.  Compiler releases happen 
often, incorporating new features, bug fixes, and small incremental changes.  
Language specification changes tend to happen on longer timescales -- there's 
not really a notion of a "minor release" on such timescales.  So, the language 
specifications are being versioned as "6.a", "6.b", "6.c", etc., instead of a 
scheme incorporating minor version increments.

Yes, this separation of language specification and implementation can be 
unnerving to those that are so used to Perl 5's tight coupling of the two, 
including using a common "version number" for both.  But that tight coupling is 
partly what led to several of Perl 5's evolutionary dead ends and roadblocks, 
and we're trying to avoid repeating that mistake with Perl 6.

Hope this helps.

Pm


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
> 
> On 2015-12-29 12:51 AM, Tobias Leich wrote:
> >Hi, the first official Perl 6 (the language) release is not called 6.0.0, it 
> >is
> >called 6.c.
> >And this is what has been shipped with the Rakudo compiler release 2015.12.
> >
> >Cheers, Tobias
> >
> >Am 27.12.2015 um 20:33 schrieb webmind:
> >>Hiya,
> >>
> >>I'm a bit confused, there is a major release for Perl 6, but I know
> >>wonder if this is the 6.0.0 release or when this will be?
> >>
> >>Thanks
> >>
> >>web
> >>
> >
> >
> 


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 'say :16<1.921fb54442d18*2**1>'
3.1415926535897931

$ ./perl6 -e 'say :16<3.243F6A8885A3>'
3.1415926535897931

> FYI Perl5 has started supporting since 5.22.

Fractional values of any radix have been in the Perl 6 design for years, and I 
suspect Rakudo has implemented it for at least 2-3 years, if not longer.

Note that the values listed above are not "floating point" (Num) -- they're 
Rats.  If you're looking specifically for the c99 hex float notation itself... 
no, Perl 6 doesn't have that AFAIK.

Pm


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 rlwrap is customizable so 
there's probably a way to get that to work somehow.

Pm

On Fri, Jan 01, 2016 at 04:47:15PM -0500, Parrot Raiser wrote:
> Is there any way to recall a previous command (for correction or
> re-running), when using Perl 6 in the interactive REPL mode?
> 
> Every time I make a typo in a complex command, I reflexively hit
> ctrl-k before remembering I'm not in bash any more.  :-)*


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 "double-ended arrow", though I don't know how
> official that name is: https://design.perl6.org/S04.html#The_for_statement
> 
> I don't know if it's actually an operator, which may be why it's hard to find.

'<->' isn't an operator, it's one of the tokens that introduces a pointy block 
term.  It's the "default to rw" form of '->' for declaring a block with 
parameters.

Pm


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 "core is { ~$ }";
}

$ ./perl6 xyz.p6
core is abc

Hope this helps,

Pm

On Mon, Feb 22, 2016 at 10:25:19AM +0100, Theo van den Heuvel wrote:
> Hi all,
> 
> I am trying to change a regex programmatically. For that I insert a variable
> in another regex. However, the match object appears to have lost the capture
> of the inner regex. In a code example:
> 
> =
> my Match $match;
> 
> my $top = rx/ \( $ = [ \w* ] \) /;
> 
> given "(abc)" {
>   $match = m/^ <$top>/;
> }
> 
> if $match {
>   say "core is { ~$ }";
> }
> 
> =
> 
> Using the latest rakudo release (2016.01.1), I find that the matching
> process works but the capture gets lost. Any ideas?
> 
> Thanks,
> 
> -- 
> Theo van den Heuvel
> Van den Heuvel HLT Consultancy
> 


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 has to be installed in order to *use* Rakudo.

For example:

"Dependency on gcc for building bash looks like a concern.  It means
that we can't have an environment with bash, without gcc."  

However, I know of a lot of systems that use bash that don't have
gcc installed, so the above statement is clearly false..  Note 
that you can replace "bash" in the statement above with things 
like "awk", "sed", or even "perl5" and it's equally as false.

As a very real example of this:  It's entirely possible TODAY for
Windows users to install and use Rakudo without having Perl 5
installed on their system.

Pm


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.

You may be disappointed to read this:  Not only is this feature preserved in 
Perl 6... it's something of a prerequisite.  It is what is required for a truly 
dynamic language that has many things happening in BEGIN blocks (i.e., things 
get executed even before you finish compiling the thing you're working on) and 
that allows dynamically adding new statement types and language features to the 
grammar.

When implementing Perl 6, I think many of us aimed to minimize the amount of 
"runtime" things that happened during the parse... only to discover that we 
actually had to embrace and formalize it instead.

Pm


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 had , , and 
grammar rules.  The grammar kept a stack of known indentation levels.
The  rule was a zero-width match that would succeed when it
found leading whitespace greater than the current indentation level
(and push the new level onto the stack).  The  rule
was a zero-width match that succeed when the leading whitespace
exactly matched the current indentation level.  And the 
rule would be called when  and  no longer 
matched, popping the top level off the stack.

So the grammar rule to match an indented block ended up looking
something like (I've shortened the example here):

token suite {
 
[   ]*
[  |  ]
}

A python "if statement" then looked like:

rule if_stmt {
'if'  ':' 
[ 'elif'  ':'  ]*
[ 'else' ':'  ]?
}

where the  subrules would match the statements or block
of statements indented within the "if" statement.

However, all of , , and  were written using
"normal" (non-regular expression) code.  Perl 6 makes this easy; since 
grammar rules are just methods in a class (that have a different code
syntax), you can create your own methods to emulate a grammar rule.  
The methods simply need to follow the Cursor protocol; that is, 
return Match objects indicating success/failure/length of whatever has 
been parsed at that point.

I hope this is a little useful.  If I can dig up or recreate a more 
complete Python implementation example sometime, I'll post it.

Pm


On Tue, Sep 13, 2016 at 01:13:45PM +0200, Theo van den Heuvel wrote:
> Hi all,
> 
> I am beginning to appreciate the power of grammars and the Match class. This
> is truly a major asset within Perl6.
> 
> I have a question on an edge case. I was hoping to use a grammar for an
> input that has meaningful indented blocks.
> I was trying something like this:
> 
>   token element { <.lm> [  | $=[ ' '+ ] )> ] }
>   token lm { ^^ ' '**{$cur-indent} } # skip up to current indent level
> 
> My grammar has a method called within the level rule that maintains a stack
> of indentations and sets a $cur-indent.
> I can imagine that the inner workings of the parser (i.e. optimization)
> frustrate this approach.
> Is there a way to make something like this work?
> 
> Thanks,
> Theo
> 
> -- 
> Theo van den Heuvel
> Van den Heuvel HLT Consultancy


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:

$ time perl -MMoose -E "say 'foo'"
foo

real0m0.190s
user0m0.172s
sys 0m0.012s

It feels like Perl 6 might at least be in the same ballpark as Perl 5 for 
similar capabilities.

Startup time is definitely something to be aware of, but most people have needs 
beyond outputting a line of text to STDOUT.

Pm


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, and CPU 
> wise.

This also seems like an interesting task for Rosetta Code (the RSA key 
generation part).  

Rosetta Code already has an entry for RSA encryption/decryption in Perl 6 (but 
not Perl), but I'm wondering if the article's version is better than Rosetta 
Code's existing Perl 6 entry.

   http://rosettacode.org/wiki/RSA_code#Perl_6

Pm


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
> variable outside the for loop and increment it, but
> I would line to know know if there is a way to incorporate
> it in the loop command.
> 
> This is my long winded way of doing it in Perl 5:
> 
> while (my ($Index, $Element) = each ( @Sorted_List ) ) { do something }
> 
> 
> Many thanks,
> -T
> 
> 
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~


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 have a compile time
> warning for the former then?

FWIW, the two snippets above are not exactly equivalent.  The scope of $x in 
the second version is limited to the block, while in the first version it 
extends beyond the if statement.

$ cat a1
if (my $x = abs(42)) { say $x; }
say "$x again";
$ ./perl6 a1
42
42 again

$ cat a2
if abs(42) -> $y { say $y; }
say "$y again";
$ ./perl6 a2
===SORRY!=== Error while compiling /home/pmichaud/p6/rakudo/a2
Variable '$y' is not declared
at /home/pmichaud/p6/rakudo/a2:2
--> say "⏏$y again";

While it might be appropriate to have a warning on simple assignment (as long 
as there's also a way to suppress the warning), I wouldn't want a warning on 
initialization, as in

if (my $x = ...) { ... }

In this case, the "my" makes it pretty clear that the assignment is intentional 
and not a typo. 

Pm


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 that used to be
> fairly important (people comparing perl 5 speed to perl 6 should take note:
> perl 5 used to be slow too).

It's not entirely a perl3-to-5ism.  Using || and && for conditional execution 
dates back to Unix shell programming (long before Perl existed); Perl 5 
introduced the low precedence "or"/"and" versions of the operators.

Pm


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;
> > >
> > > fwiw I consider this a perl3_to_5-ism; it's an optimization, and a fairly
> >
> > It's not entirely a perl3-to-5ism.  Using || and && for conditional
> > execution dates back to Unix shell programming (long before Perl existed);
> > Perl 5 introduced the low precedence "or"/"and" versions of the operators.
> 
> True, but I don't really consider shells to be full programming languages;
> they exist to glue external programs together. 

and FWIW, Perl was long known as a "glue language" as well.  :)

> If you have an actual programming language around, there's no reason to
> stick to unreadable JCL-ish constructs.

...unless you have a large audience of people that are fluent in those 
constructs and would like to continue using them in their shiny new programming 
environment.

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
$str = 'bar'; 
say 'foo' ~~ $foorx;   # still matches... $foorx is unchanged

$ ./perl6 rxstr
「foo」
「foo」

And for a bit more golfing, there's:

my $str = 'foo';
my $foorx = { rx/<$^a>/ }.($str);

say 'foo' ~~ $foorx;

Pm


On Fri, May 12, 2017 at 01:01:17AM +0200, Timo Paulssen wrote:
> The only way that comes to mind is to use EVAL, but that's not
> golf-friendly at all.
> 
> Perhaps you can find something sufficiently short based on .contains,
> .index, .starts-with, .ends-with, and friedns?


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: 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) lets us use de-facto interfaces and easily override it in a
> user module.

FWIW, the idea has always been that NQP provides a simple, default REPL for 
tools/languages being built using NQP, and then languages can then 
override/augment that REPL as desired.

Pm


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 the original intent was for .WHY to work in this manner -- it's 
intended to provide the attached Pod value.

I don't know to what level Rakudo implements this yet.

There's an example given at https://docs.perl6.org/routine/WHY .

Pm


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: 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.
> >
> > I saw a business study somewhere (I don't remember where)
> > that determined that the notes folks doodle into the margins on
> > working papers are often time more useful than the papers
> > themselves.  One wonders how much of this happens in Perl!
> 
> That'd be comments, actually. Sadly, the same rule doesn't seem to apply;
> programmers are terrible at writing useful comments for the most part.

True, but when programmers do manage to write useful comments, they often turn 
out to be VERY useful.  :)

Pm


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 inverting the entire regex -- i.e., instead 
of matching finding things that do match, exclude the things that don't:

   / gm | <-[d..z]> /

This regex will match any string containing the sequence "gm" or any character 
that isn't in the range "d".."z", which is the inverse of what was required 
(strings containing only "d".."z" and never "gm").  Then use !~~ or some 
similar logic to get the strings wanted.

I recognize that this approach might not fit well in all cases, but it's 
another (perhaps cleaner) approach to getting what's wanted.

Pm


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:
> > > > 
> > > >    / ^ <[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 inverting the entire regex -- i.e., 
> > instead of matching finding things that do match, exclude the things that 
> > don't:
> > 
> > / gm | <-[d..z]> /
> > 
> > This regex will match any string containing the sequence "gm" or any 
> > character that isn't in the range "d".."z", which is the inverse of what 
> > was required (strings containing only "d".."z" and never "gm").  Then use 
> > !~~ or some similar logic to get the strings wanted.
> > 
> > I recognize that this approach might not fit well in all cases, but it's 
> > another (perhaps cleaner) approach to getting what's wanted.
> 
> Something is wrong.  "h" is in the exclude list.
> 
> $ p6 'if "hgm" ~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
> y

The string "hgm" is in the "not include" list for the other regex as well 
(because it contains "gm"):

$ perl6 -e 'if "hgm" ~~ /  ^ <[d..z]>* $/ { say "n" } else { say 
"y" }'
y


Pm


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, 
Perl 6 is designed to be very dynamic.  The compiler actually executes some 
components of the program as it scans them -- i.e., before it's had a chance to 
check (or even read) the entire source code file.  

So it's a little challenging in Perl 6 to say "but not actually run the 
program".  

A more accurate/do-able thing might be to simply say "load everything but don't 
run the mainline".  In code this could perhaps be achieved with something like:

   INIT { exit 0; }

This means that BEGIN and CHECK blocks still run, as well as potential other 
declarations that have executable side effects, but the mainline doesn't ever 
get run.  Perhaps there's a case to be made that "-c" or a similar option 
should do something like this, or have "-c" simply stop after the CHECK phase 
of evaluation.

Pm


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 {
>@lines.push($l);
>take @lines if /''/;
>}
> }
> }
> }
> 
> this doesn't work as it seems that '›' and '' aren't matched.

Is it as simple that the  /'›'/  regex is being matched against $_ instead of 
$l ?  

If I'm reading the above code correctly, $_ is being set to each of the values 
of @ARGS in turn.  The lines iterated by the for loop are all being bound to 
$l, meaning $_ is unchanged from its outer (map) meaning.

Pm


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 supposed to determine exactly what thing it is? Not sure about
> that. The + and - is a bit like "start at nothing, add all alnums, then
> subtract all alphas". The + after the < > is just to match it any number
> of times, but at least once, and the $ at the end, together with the ^
> at the start, ensures that every character in the string has to match,
> not just any character.
> 
> Hope that makes sense
>   - Timo
> 
> 
> On 03/08/18 20:04, ToddAndMargo wrote:
> > On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> >> Is this what you want?
> >>
> >> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> >> 「12345」
> >>
> >> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> >> Nil
> >>
> >> HTH
> >>    - Timo
> >>
> >
> > What does the following do?
> >
> >  +alnum   (why does it need the "+"?)
> >  -alpha   (I presume "-" means negate?)
> >  +$
> >
> > Many thanks,
> > -T


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) } rescue -1;
say "6/2 = ", $sixdivtwo;


$ perl6 t.p6
6/0 = -1
6/2 = 3


Or if you prefer a prefix form, just declare "rescue" as a normal sub and then 
do:

   rescue { divide(6,2) }, -1;

Pm

On Fri, Aug 03, 2018 at 08:34:44PM +0100, Simon Proctor wrote:
> Hi Sean. I hope my second answer in stackoverflow gets closer to what you
> want.
> 
> I am still trying to think of a more idiomatic way of handling to situation.
> 
> 
> 
> On Fri, 3 Aug 2018, 19:29 Sean McAfee,  wrote:
> 
> > I posted about this subject on Stack Overflow yesterday[1], but I chose a
> > poor example of something that raises an exception (dividing by zero, which
> > apparently doesn't necessarily do so) on which the answers have mostly
> > focused.
> >
> > I was looking for a way to evaluate an expression, and if the expression
> > threw an exception, for a default value to be provided instead.  For
> > example, in Ruby:
> >
> > quotient = begin; a / b; rescue; -1; end
> >
> > Or in Lisp:
> >
> > (setq quotient (condition-case nil (/ a b) (error -1)))
> >
> > Not having written much exception-related code in Perl 6, I hoped that
> > this might work:
> >
> > sub divide($a, $b) { die "Zero denominator" if $b == 0; $a / $b }
> > my $quotient = do { divide($a, $b); CATCH { default { -1 } } };
> >
> > It doesn't, though.  As far as I can tell, the value to which a CATCH
> > block evaluates is ignored; the only useful things one can do in such a
> > block are things with side effects.  Long story short, I eventually came up
> > with this:
> >
> > my $quotient = do { my $q; { $q = divide($a, $b); CATCH { default { $q
> > = -1 } } }; $q };
> >
> > That's far more verbose than I've come to expect from Perl 6.  Is there
> > some more concise way of expressing this logic?
> >
> > The doc page on exceptions mentions try, eg:
> >
> > my $quotient = try { divide($a, $b) } // -1;
> >
> > That works in this specific case, but it seems insufficient in general.
> > The function might validly return an undefined value, and this construction
> > can't distinguish between that and an exception.  Also, it wouldn't let me
> > distinguish among various exception cases.  I'd have to do something like:
> >
> > class EA is Exception { }
> > class EB is Exception { }
> > sub divide($a, $b) { (EA, EB).pick.new.throw if $b == 0; $a / $b }
> >
> > my $quotient = do { my $q; { $q = divide($a, $b); CATCH { when EA { $q
> > = -1 }; when EB { $q = -2 } } }; $q };
> >
> >
> > [1]
> > https://stackoverflow.com/questions/51644197/returning-values-from-exception-handlers-in-perl-6/51670573
> >
> -- 
> Simon Proctor
> Cognoscite aliquid novum cotidie


Re: Catching exceptions in expressions

2018-08-03 Thread Patrick R. Michaud
Yes; but then I think that something like infix: probably just ends up 
as a macro somehow.  I just didn't know the state of macros in Perl 6 well 
enough to be able to head down that route.  :)

Pm

On Fri, Aug 03, 2018 at 10:32:41PM +0200, Elizabeth Mattijsen wrote:
> Sometimes I wish 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 2018, at 22:18, Patrick R. Michaud  wrote:
> > 
> > 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) } rescue -1;
> > say "6/2 = ", $sixdivtwo;
> > 
> > 
> > $ perl6 t.p6
> > 6/0 = -1
> > 6/2 = 3
> > 
> > 
> > Or if you prefer a prefix form, just declare "rescue" as a normal sub and 
> > then do:
> > 
> >   rescue { divide(6,2) }, -1;
> > 
> > Pm
> > 
> > On Fri, Aug 03, 2018 at 08:34:44PM +0100, Simon Proctor wrote:
> >> Hi Sean. I hope my second answer in stackoverflow gets closer to what you
> >> want.
> >> 
> >> I am still trying to think of a more idiomatic way of handling to 
> >> situation.
> >> 
> >> 
> >> 
> >> On Fri, 3 Aug 2018, 19:29 Sean McAfee,  wrote:
> >> 
> >>> I posted about this subject on Stack Overflow yesterday[1], but I chose a
> >>> poor example of something that raises an exception (dividing by zero, 
> >>> which
> >>> apparently doesn't necessarily do so) on which the answers have mostly
> >>> focused.
> >>> 
> >>> I was looking for a way to evaluate an expression, and if the expression
> >>> threw an exception, for a default value to be provided instead.  For
> >>> example, in Ruby:
> >>> 
> >>>quotient = begin; a / b; rescue; -1; end
> >>> 
> >>> Or in Lisp:
> >>> 
> >>>(setq quotient (condition-case nil (/ a b) (error -1)))
> >>> 
> >>> Not having written much exception-related code in Perl 6, I hoped that
> >>> this might work:
> >>> 
> >>>sub divide($a, $b) { die "Zero denominator" if $b == 0; $a / $b }
> >>>my $quotient = do { divide($a, $b); CATCH { default { -1 } } };
> >>> 
> >>> It doesn't, though.  As far as I can tell, the value to which a CATCH
> >>> block evaluates is ignored; the only useful things one can do in such a
> >>> block are things with side effects.  Long story short, I eventually came 
> >>> up
> >>> with this:
> >>> 
> >>>my $quotient = do { my $q; { $q = divide($a, $b); CATCH { default { $q
> >>> = -1 } } }; $q };
> >>> 
> >>> That's far more verbose than I've come to expect from Perl 6.  Is there
> >>> some more concise way of expressing this logic?
> >>> 
> >>> The doc page on exceptions mentions try, eg:
> >>> 
> >>>my $quotient = try { divide($a, $b) } // -1;
> >>> 
> >>> That works in this specific case, but it seems insufficient in general.
> >>> The function might validly return an undefined value, and this 
> >>> construction
> >>> can't distinguish between that and an exception.  Also, it wouldn't let me
> >>> distinguish among various exception cases.  I'd have to do something like:
> >>> 
> >>>class EA is Exception { }
> >>>class EB is Exception { }
> >>>sub divide($a, $b) { (EA, EB).pick.new.throw if $b == 0; $a / $b }
> >>> 
> >>>my $quotient = do { my $q; { $q = divide($a, $b); CATCH { when EA { $q
> >>> = -1 }; when EB { $q = -2 } } }; $q };
> >>> 
> >>> 
> >>> [1]
> >>> https://stackoverflow.com/questions/51644197/returning-values-from-exception-handlers-in-perl-6/51670573
> >>> 
> >> -- 
> >> Simon Proctor
> >> Cognoscite aliquid novum cotidie


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.

Phrased another way, the  rule as written now is roughly equivalent to 
writing

   token other { .  \s* }

which will match a word character only when it's not immediately followed by 
another word character.

Pm


On Sun, Sep 23, 2018 at 08:01:31PM -0400, yary wrote:
> Let's see.
> 
> If you have my $input = '~i o<<<', then  matches.
> 
>  'rule' turns on :sigspace. If you use 'token' instead of 'rule' then
>  matches.
> 
> I don't quite have the full picture of what's happening.
> 
> -y
> 
> On Sun, Sep 23, 2018 at 7:07 PM, Mark Carter  wrote:
> 
> > My grammar doesn't seem to match the 'other' rule. What's wrong with it?
> >
> > grammar Weave {
> > token TOP {   * }
> > rule el {   |  |   }
> > rule lt { '<'  }
> > rule tilde { '~' \S+ }
> > rule other { .  }
> > }
> >
> > class Weaver {
> > has Str $.outstr;
> >
> > method TOP   ($/) { make $ ; put("top called") ; put($) }
> > method el($/) { put($/) }
> > method tilde ($/) { say 'tilde called' }
> > method lt($/) { make '<' ; put('<'); $!outstr ~= 'X' }
> > method other ($/) { $!outstr ~= '.'; say 'other called'; put('.');
> > }
> >
> > }
> >
> > $input = '~i << > my $w = Weaver.new();
> > Weave.parse($input, :actions($w));
> > say $w.outstr; # outputs XXX
> >
> > It never once says 'other called'. It seems to be matching the '<' signs
> > OK, and I think the '~' is OK, too. It's just any other token that it's not
> > matching.
> >


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>
> 
> Certainly very practical.  If dealing with large strings, is
> it the most efficient?

.comb is intended to be more efficient than .split for this particular 
application, yes.

"comb" is about obtaining the substrings you're looking for (individual 
characters in this case); "split" is about finding substrings between the 
things you're looking for.

Pm


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 .*?, so that the expresssion is 
greedy instead of eager.

Pm


On Mon, May 06, 2019 at 07:12:39PM -0700, Tony Ewell via perl6-users wrote:
> Hi All,
> 
> What am I doing wrong here?
> 
> $ p6 'my $x="\$1.23"; $x~~s/("\$") (.*?)/$1USD/; say $x;'
> USD1.23
> 
> I am expecting to see  `1.23USD`
> 
> Many thanks,
> -T


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 that this question arose this
> past weekend at a Perl6 Meetup (Oakland, CA). Specifically we were
> looking at how to write a Perl6 version of some introductory Perl5
> code in "Learning Perl", 7th Edition by Tom Phoenix, brian d foy,
> Randal L. Schwartz:
> 
> #Perl 5 code below:
> while (<>) {
>   chomp;
>   print join("\t", (split /:/)[0, 2, 1, 5] ), "\n";
> }
> 
> https://www.oreilly.com/library/view/learning-perl-7th/9781491954317/ch01.html
> 
> (Thanks to Joseph Brenner for organizing the Perl6 Meetup).
> 
> 
> 
> 
> 
> 
> On Mon, Jul 29, 2019 at 2:09 AM Elizabeth Mattijsen  wrote:
> >
> > Also, you can make this conditional:  show me all the comment lines of a 
> > source file:
> >
> >
> > $ perl6 -e '.say if .starts-with('#') for lines' source-file
> >
> >
> > > On 29 Jul 2019, at 10:06, Richard Hainsworth  
> > > wrote:
> > >
> > > Also no need for all the brackets
> > >
> > > .say for lines;
> > >
> > > This is quite idiomatic Perl 6 and not golfing
> > >
> > > On Mon, 29 Jul 2019, 07:13 Joseph Brenner,  wrote:
> > > > Hmmm. I would expect that to be in the Perl 5 to Perl 6 Migration 
> > > > Guides, but I do not see it there.
> > >
> > > Exactly, I was just looking there, and I ended up playing around with
> > > the method form of lines, and didn't think to try the function
> > > form of it.
> > >
> > > To summarize, if the goal is to write a "simple_echo" script that
> > > can work with a file name or with lines on standard input:
> > >
> > >simple_echo lines.txt
> > >cat lines.txt | simple_echo
> > >
> > > The perl5 version would probably be:
> > >
> > >   #!/usr/bin/env perl
> > >   while(<>){
> > >  print;
> > >   }
> > >
> > > The perl6 version would be something like:
> > >
> > >   #!/usr/bin/env perl6
> > >   use v6;
> > >   for lines() {
> > >   say $_;
> > >   }
> > >
> > >
> > > The kind of thing I was playing with was:
> > >
> > >   #!/usr/bin/env perl6
> > >   use v6;
> > >   my @lines = $*ARGFILES.IO.lines;
> > >   say @lines;
> > >
> > > That works for lines from a file, but not from standard input, and  the
> > > error message isn't tremendously helpful:
> > >
> > >   No such method 'lines' for invocant of type 'IO::Special'
> > >
> > >
> > >
> > >
> > > On 7/28/19, Bruce Gray  wrote:
> > > >
> > > >
> > > >> On Jul 28, 2019, at 6:20 PM, Joseph Brenner  wrote:
> > > >>
> > > >> I was just wondering if there's some direct analog in perl6 to the
> > > >> perl5 construct:
> > > >>
> > > >>  while(<>){ ... }
> > > >>
> > > >> If I'm planning on passing a filename on the command-line, I can just
> > > >> get it out of $*ARGFILES easily enough, but what if I also wanted it
> > > >> to work on lines passed in via standard input?
> > > >
> > > >
> > > > `lines` , as a sub instead of a method, and no arguments.
> > > >
> > > > See: https://docs.perl6.org/routine/lines#(Cool)_routine_lines
> > > >   Without any arguments, sub lines operates on $*ARGFILES, which 
> > > > defaults to
> > > > $*IN in the absence of any filenames.
> > > >
> > > > For example:
> > > >   perl6 -e 'say .join("\t") for lines().rotor(4);' path/to/file.txt
> > > >
> > > > Hmmm. I would expect that to be in the Perl 5 to Perl 6 Migration 
> > > > Guides,
> > > > but I do not see it there.
> > > >
> > > > —
> > > > Hope this helps,
> > > > Bruce Gray (Util of PerlMonks)
> > > >
> > > >


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 37 38>
> "1234\r\n78".encode.subbuf(*-4).decode

78

Pm


On Mon, Feb 10, 2020 at 02:38:19PM -0500, Paul Procacci wrote:
> Unicode conformance requires "\r\n" to be interpreted as \n alone.
> With that said; no, I don't not know how to turn this off.
> 
> I personally think I'd consider this a bug.  If not a bug, greater
> documentation efforts that explain this.
> The display routines (say / print) don't modify the string on output, yet
> the other string handling routines do.
> 
> We'd need further clarification from the devs as I don't have a full grasp
> of the design decision for this problem.
> 
> On Mon, Feb 10, 2020 at 11:28 AM David Santiago  wrote:
> 
> > A 10 de fevereiro de 2020 16:57:55 CET, David Santiago 
> > escreveu:
> > >
> > >
> > >Hi!
> > >
> > >Is there a way to change the the following behaviour, so it considers
> > \r\n as two characters when using substr, instead of one?
> > >
> > >On raku version 2019.11
> > >
> > >> "1234\r\n". substr(*-4)
> > >4
> > >78
> > >> "1234\r\n". substr(*-4).ords()
> > >(52 13 10 55 56)
> > >
> > >
> > >Best regards,
> > >David Santiago
> > >
> >
> > Copied wrong the example:
> >
> > It should be:
> >
> > On raku version 2019.11
> >
> > > "1234\r\n78". substr(*-4)
> > 4
> > 78
> > > "1234\r\n78". substr(*-4).ords()
> > (52 13 10 55 56)
> >
> >
> >
> > --
> > Sent from my Android device with K-9 Mail. Please excuse my brevity.
> >
> 
> 
> -- 
> __
> 
> :(){ :|:& };:


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.WHERE   # I expected FALSE
> True
> 
> To a bound variable, I expect the same address, but to an unbounded
> variable, this garbage collector behavior seams assing to the same memory
> location two unbounded variables with the same value. It is right? Must
> reduce memory usage but is a quiet weirdo.

I don't know that it's "weirdo" that two variables containing the same 
(constant, immutable) value end up at the same address.  It's just the compiler 
treating constants as proper objects and being smart about memory allocation.

In particular:

> my $a = 3; say $a.WHERE
94659198947472
> $a = 4; say $a.WHERE
94659198947432
> $a = 3; say $a.WHERE
94659198947472

What's likely happened is that the compiler has created an Int representing the 
constant "3", and keeps track of that for future compilations.  Whenever the 
compiler encounters another "3", rather than build a new Int object in memory 
it re-uses the Int it already established if it can.

So, with

> my $b = 3; say $b.WHERE
94659198947472

The compiler lets $b use the same constant 3 object that was created the first 
time it was encountered, even though $a coincidentally also uses it.

> $b = 6 div 2;  say $b; say $b.WHERE
3
139719166700504

The compiler has gone ahead and used "6 div 2" to produce a new Int object, 
which has the same value as the constant 3 but is in a different memory 
location.  If we then do

> $b = 3; say $b.WHERE
94659198947472

you can see that the constant "3" Int is still hanging around to be used 
wherever it's later mentioned in the code.

Hope this helps,

Pm


Re: In lieu of "This Week in Perl 6"

2008-04-13 Thread Patrick R. Michaud
On Sat, Apr 12, 2008 at 11:52:44PM +0200, Moritz Lenz wrote:
> Conrad Schneiker wrote:
> > Also, please consider referring people to the Perl 6 wiki (and
> > any relevant subsections thereof) for more information when
> > writing things that may get wider attention beyond the immediate
> > Perl 6 community.
> 
> and if you find things on http://dev.perl.org/perl6/ to be wrong or
> outdated, feel free to contact me, and I'll send a patch to our webmasters.
> I tried to update the most important parts (without being too
> intrusive), but it's surely not complete.

The biggest things I notice:

- The link to the Perl 6 Wiki on http://dev.perl.org/perl6/ is broken
  (it's an xrl.us link that takes me to a totally unrelated Herald-Sun 
  page).

- The sidebar links should be updated.  It might be good to update
  the "Talks", "Who's Who", and "Status" links to point to the
  appropriate pages on the Perl 6 wiki.

- Along the same lines, it might be nice to have the "Perl 6 FAQ"
  on the wiki instead of the static (and somewhat out of date)
  page we have now.  Also, the Perl 6 wiki has a link to an
  excellent (perhaps slightly out of date) FAQ at
  http://www.programmersheaven.com/2/Perl6-FAQ .  Perhaps
  we could arrange with Jonathan and/or Programmers Heaven
  to get some of those items migrated to the wiki for easy
  updating?

- The copyright date is given as 2005.  :-)

Hope this helps,

Pm


Re: Recommended Perl 6 best practices?

2008-09-14 Thread Patrick R. Michaud
On Sun, Sep 14, 2008 at 04:18:44PM +0200, Carl Mäsak wrote:
> Conrad (>):
> > Is there something more up-to-date concerning "Perl 6 best practices" that
> > are presently-recommended (by p6l or @Larry) than the following item on the
> > Perl 6 wiki?
> [...]
> That said, I do have one Perl 6-specific "best practice". I know
> you're looking for a collection, but one's a start. :) Here it is:
> 
> Do not combine 'ne' and '|', like this:
> 
> die "Unrecognized directive: TMPL_$directive"
>if $directive ne 'VAR' | 'LOOP' | 'IF';
> [...]
> The more general advice, then, would be not to use junctions together
> with negated equality operators. Instead, use the non-negated equality
> operator, and negate the whole expression.

This particular case is explicitly mentioned in S03:2529:

Use of negative operators with syntactically recognizable junctions may
produce a warning on code that works differently in English than in Perl.
Instead of writing
if $a != 1 | 2 | 3 {...}
you need to write
if not $a == 1 | 2 | 3 {...}

However, this is only a syntactic warning, and
if $a != $b {...}
will not complain if $b happens to contain a junction at runtime.

We might be able to craft a similar warning in Rakudo, but I'm
curious to see how/where STD.pm will choose to handle this.
(My guess is it will have something to do with 
infix_prefix_meta_operator:, although we also have to have a way
to handle it for the infix: and infix: cases.)

Pm


Re: Recommended Perl 6 best practices?

2008-09-30 Thread Patrick R. Michaud
On Tue, Sep 30, 2008 at 02:31:46PM +1000, Jacinta Richardson wrote:
> Carl Mäsak wrote:
> > The "correct" form using junctions would be this:
> > 
> > die "Unrecognized directive: TMPL_$directive"
> >if $directive ne 'VAR' & 'LOOP' & 'IF';
> 
> which makes sense, because this does give us:
> 
>   $directive ne 'VAR' && $directive ne 'LOOP' && $directive ne 'IF'

Just for pedantic clarity, what C< $directive ne 'VAR' & 'LOOP' & 'IF' >
really gives is

all( $directive ne 'VAR', $directive ne 'LOOP', $directive ne 'IF' )

In other words, the result of the expression is an all() Junction.
In boolean context this would indeed evaluate to false if $directive
has any of the values 'VAR', 'LOOP', or 'IF'.

Pm


Re: Argument scoping error or bug?

2008-10-27 Thread Patrick R. Michaud
On Sat, Oct 25, 2008 at 10:52:13AM +0200, Moritz Lenz wrote:
> Chris Dolan wrote:
> > I stumbled across this issue while descending into a recursive Match  
> > structure.  Consider the following reentrant subroutine:
> 
> You have just experienced this bug:
> http://rt.perl.org/rt3/Ticket/Display.html?id=58392
> "Recursion and for loops interact badly in Rakudo".
> 
> Patrick is working on it.

That said, I'm also looking for others to help work on it.  
But it's not a pretty bug, and it's deeply embedded in 
Parrot internals.  :-)

Pm


Re: Why {{}} for regexp closures instead of just {}?

2008-10-28 Thread Patrick R. Michaud
On Mon, Oct 27, 2008 at 04:07:39PM -0500, [EMAIL PROTECTED] wrote:
> > On Sun, Oct 26, 2008 at 10:45 PM, Chris Dolan <[EMAIL PROTECTED]> wrote:
> >> S05 always uses single curlies for closures, but throughout Parrot, code
> >> seems to use double curlies in PGE regexps.  Why is that?
> >>
> >> That is, why this:
> >>  m/ foo {{ say "found foo" }} /
> >> and not this:
> >>  m/ foo { say "found foo" } /
> >>
> >> The latter complains about "Statement not terminated properly".
> >>
> > this is old PGE syntax that hasn't yet been updated to match S05. it's a
> > bug.

Sometimes working with Parrot is a lesson in archaeology -- by
digging deep enough you see artifacts of a different age.

In order to properly parse curlies in regexes one has to have
a full-fledged (Perl 6 / Python / PHP/ whatever) parser available 
to be able to find the closing curly.  Long ago, before we had
any such parsers, people wanted to be able to embed executable
code inside of regexes -- indeed, the parsers themselves make use
of this capability.  So, PGE used the double-curly notation as
a stop-gap -- it can easily "scan ahead" to the closing double-curly
to find the end of the embedded code and squirrel it away for
execution.

This was all done before S05 defined the :lang modifier for
embedded closures in regexes, and at the moment it only works
for embedding PIR.

Returning to present day, the next step will be to enable the
:lang modifier in regexes so that it can attach to any compiler.
However, since Perl 6 regular expression parsing is about to
receive a huge makeover anyway, I was waiting until then to
work out those details.

> Thanks for the info.  I'll try to learn enough to write a PGE patch to
> support {PIR} notation.  

Note that {PIR} is not valid by itself, it would need to be

:lang('PIR') {PIR}

or something like that.  See S05 for the latest syntax.  The default
interpretation of curlies with no :lang modifier will undoubtedly 
be Perl 6 syntax (although we may make it default to "whatever
language the regex is embedded in" if we can do that).

Pm


Rakudo bug reports still go to [EMAIL PROTECTED]

2008-11-19 Thread Patrick R. Michaud
Some of you may have seen the announcements on the Parrot
lists that Parrot will be starting to use trac.parrot.org 
for its issue tracking and bug reporting system.

This is just a note that Rakudo's bug reports will continue
to be hosted on the rt.perl.org server, and we will continue
to use <[EMAIL PROTECTED]> for submitting new issues and
bug reports.

In addition, sometime before the February 2009 release we
expect to move the Rakudo sources out of the Parrot repository
and into a separate location at svn.perl.org.  More details
on this as we get closer to doing so.

Thanks!

Pm


Re: grammar question

2008-11-29 Thread Patrick R. Michaud
On Sat, Nov 29, 2008 at 05:57:07PM +1000, Илья wrote:
> Hi there,
> I have tried to fix our HTML::Template in November which is blocked by
> Rakudo segaful.
> I was trying to create simple example, but can`t reproduce it.  By the
> way now I have short
> example(much shorter then when I start), and I have questions about it:
> 
> grammar G {
> token TOP { ^ + $ };
> token foo { ':' ?  };
> token bar { \w };
> };
> 
> ":a:b" ~~ G::TOP;
> 
> say ~$/; #:a
> 
> # why ':a'? why not just 'a'?

$/ is an array of Match objects, and Parrot currently
doesn't distinguish between array indexes and hash indexes --
it treats them both the same.

Thus $/   is ending up acting the same as  $/['bar'],
and since 'bar' stringifies to zero that's the same as $/[0],
which includes the colon.

The correct way to get just the  component would be

$/[0][0]

since both  and  are quantified subrules in the grammar.

Pm


Re: .kv

2008-12-14 Thread Patrick R. Michaud
On Sun, Dec 14, 2008 at 11:55:54PM +1000, Илья wrote:
> (23:24:09) ihrd: hi
> (23:24:28) ihrd: question about .kv
> (23:24:39) ihrd: rakudo: my @a = {a => 1}, {b =>2}; my %h = foo => @a;
> say %h.kv.perl;
> (23:24:41) p6eval: rakudo 33880: OUTPUT[["foo", {"a" => 1}, {"b" => 2}]␤]
> (23:24:59) ihrd: rakudo: say ({ foo => [{a=>1}, {b=>1}]}).perl;
> (23:25:02) p6eval: rakudo 33880: OUTPUT[{"foo" => [{"a" => 1}, {"b" => 1}]}␤]
> (23:25:22) ihrd: I feel result should be the same
> (23:25:29) ihrd: I miss something?

Hash assignment and .kv are still not working perfectly in Rakudo yet --
it's on my list to fix along with hash slices.  Hash slices are
a bit trickier at the moment because Rakudo's implementation of
WHENCE clauses currently depends on the existing implementation
of postcircumfix:<{ }>, so that has to be fixed first.

Pm


Perl 6 Scripting Games

2008-12-22 Thread Patrick R. Michaud
Are you interested in playing with Perl 6 and Rakudo Perl but can't 
figure out what to do? Here's an idea that came up during Jon Allen's 
talk "The Camel and the Snake" [1] at YAPC::EU in Copenhagen.

For the past few years Microsoft has sponsored an annual 
Scripting Games [2] competition, where they publish problems of 
varying difficulty levels to be solved using Perl 5, VBScript, 
Python, or other languages. I think it might be very interesting 
and useful to see people develop and publish Perl 6 solutions 
to those problems.

So, here's my idea: If you're interested in learning more about 
Perl 6, select one or more problems from the Scripting Games 
website, develop solution(s) for them in Perl 6, and then publish 
your solutions somewhere along with a description of what you 
like, don't like, learned, didn't learn, etc. about Perl 6 and 
Rakudo Perl.

One of the things we've observed from our experience with the 
November Wiki [3] and other similar projects is that having "running 
code examples" and "real problems" is one of the best drivers for 
compiler and language development. I'm thinking that having people 
craft solutions to the scripting problems might do more of the 
same for Rakudo, while also sparking discussion and reflection on 
Perl 6 itself.  

So, where to start? Start by obtaining and building a copy of 
Rakudo Perl [4], write and test your solutions to one or more problems, 
and post the results and your experiences somewhere for others 
to see. You can post to use.perl.org, your private blog, the 
perl6-users mailing list, or anywhere else you find convenient. 
The point isn't to develop a centralized repository of solutions 
(although we can do that), but rather to use the problems as a 
way to spread discussion, feedback, and experience with Perl 6.

I should also make it plain that people are very likely to run 
into some of Rakudo Perl's "rough edges" -- places where we don't 
yet implement key features or where they don't work exactly as 
they're supposed to. But to the designers and implementors that's 
part of the point -- we need to know where those rough edges are. 
Overall, I'm hoping that with the recent improvements to Rakudo 
Perl [5] there won't be so many rough edges as to make the effort more 
disappointing than enjoyable. And there are lots of people eager 
to answer questions and help out on the perl6-users mailing list, 
IRC #perl6 (irc.freenode.net), and other common Perl forums. 
It's all about learning and improving what we have with Perl 6.

I look forward to seeing your questions and answers.

Happy holidays,

Pm 

1. The Camel and the Snake, http://www.yapceurope2008.org/ye2008/talk/1365
2. The Scripting Games, 
http://www.microsoft.com/technet/scriptcenter/funzone/games/default.mspx
3. November Wiki, http://github.com/viklund/november/tree/master
4. Rakudo Perl README, http://svn.perl.org/parrot/trunk/languages/perl6/README
5. Rakudo Perl Twitter feed, http://twitter.com/rakudoperl



Re: reporting bugs

2009-01-04 Thread Patrick R. Michaud
On Sun, Jan 04, 2009 at 05:20:56PM +0300, Richard Hainsworth wrote:
> I posted an email to per6-all asking about how one should go about  
> reporting bugs. That message has appeared on the list.
>
> So again: how can bugs be reported?

See the "Reporting bugs" section of README file in languages/perl6.

(Honestly, I don't know why we call such files "README", since nobody
ever does.  I think I'll rename the file to "IGNOREME" -- maybe it'll
get some attention then. :-)

> Eventually, I found reference to perlbug and opened an account. But I  
> cant find a way to submit a bug.
>
> Some requests:
> a) When I strike a bug, perl6 (rakudo) dumps alot. Could this behaviour  
> be modified with a verbose option on the perl6 command line?

I'm working on this.  Parrot doesn't give us a lot of control over
backtrace behavior at the moment -- it's either all-or-nothing.
I might implement a switch somewhere.

> b) Also, what needs to be stated? I used svn to download the latest  
> parrot. So, I should be stating the latest revision number. "perl6 -v"  
> doesnt provide this.

We haven't come up with a good way to fetch the latest revision number
for use with a -v option to perl6.  If you know of one (and that will 
work even if someone obtains Rakudo via tarball or git or a non-svn
mechanism), we can certainly add it.

> I was going to describe the bugs, but I just checked the test results in  
> S05 and found the things I cant get working are not yet implemented.
>
> There isnt any table of these anywhere. Could we get one?

http://www.perlfoundation.org/perl6/index.cgi?rakudo%20feature%20status

Feel free to modify this list.

>
> Patrick! Do you want feed back about things that cant be done, but  
> should be done?
>
> If so, I would like to have m:i/ / and m/ a {say 'yes'} /

m:i/ ... /  can currently be done with  /:i ... / .

Getting closures to work inside of regexes is a bit tricky at the
moment, because it implies that PGE (our regex engine) has to
know how to call the Perl 6 parser and do the right thing with
whatever it gets back.  That's coming in the not-too-distant
future, but it's by no means "trivial" to implement.

Pm


Re: not wanting something

2009-01-06 Thread Patrick R. Michaud
On Tue, Jan 06, 2009 at 12:42:16PM -0500, Chas. Owens wrote:
> On Tue, Jan 6, 2009 at 10:12, Patrick R. Michaud  wrote:
> snip
> > Also, Perl 6 already provides a 'digit' rule by default, although
> > it's digits in the Unicode sense as opposed to simply the 0..9
> > sequence.
> snip
> 
> Please tell me that Perl 6 isn't going to make that same error the
> Perl 5.8 did.  

As far as I know,  means "Unicode alphabetic", and by analogy
one presumes that  is "Unicode digit".

> Or at least tell me that it will provide two classes:
> Unicode digit and digit you can do math with.  

It's entirely possible that in Perl 6 one can "do math" with
strings containing Unicode digits, making the distinction 
somewhat irrelevant, perhaps.  (I don't have proof of this, but 
I suspect it to be the case.)

I know that magical string autoincrement honors Unicode digit
sequences, at any rate.

Pm


Re: what is going on here?

2009-01-13 Thread Patrick R. Michaud
On Mon, Jan 12, 2009 at 12:11:59PM +0300, Richard Hainsworth wrote:
> But
> my @ranking = %players.sort :{.value}; # white space before :, no ws after :
>
> generates a syntax error with rakudo.
> Is this a raduko bug, or am I not understanding your generic argument?

Rakudo doesn't recognize adverbial blocks yet (i.e., a colon followed 
by braces).

Pm


Re: A Logo design for Rakudo Perl 6

2009-01-16 Thread Patrick R. Michaud
On Fri, Jan 16, 2009 at 03:45:48AM -0700, Perl wrote:
> Moritz was one of the first to guide it to the idea of making a logo for 
> Rakudo Perl 6 - as there's nothing yet (really) available. I thought that 
> would be a neat project and scratch some of my person itches.

It would be a very neat project.  It will solve some immediate and 
pressing needs.

> Here's some notes I've collected about what people have said Rakudo Perl 
> 6 is, which is a good baseline on what a logo should try to reflect and 
> communicate:
> [...]

I'll start with my summarized thoughts first, then a few specifics below.
First, I totally agree that Rakudo Perl needs a logo, and the sooner 
we can get one to start using on our website (which we're now creating)
and other materials, the better.  So, your thoughts and ideas are
quite welcome.

Beyond that, I think your message has neatly captured many of the facets
of what we're working with (and yes, there are a lot of facets).  The
message reminds me of some of Larry's "State of the Onion" addresses --
looking at many sides of the Perl (in this case Rakudo Perl 6) world.

So, my primary comment is that I find myself very much in agreement
with your proposal, and a strong hope that you'll continue on in this
direction.  I agree with the idea of the style guide and some simple 
elements that people can combine together in very expressive and
beautiful ways.  Indeed, it sounds very much like you're proposing
an ideographic system for Rakudo Perl, where can combine graphic
symbols for ideas together.  That feels very Perlish and Rakudoish
to me -- I like it.

So, I'd say "press on" and let us see what you come up with.  :-)

Some other minor reflections on your post:

> One of the main fears with this name, "Rakudo Perl 6" - at least when it 
> first came out, is that describing Rakudo Perl as, "An implementation 
> (one of possibly, many) of the Perl 6 Specification, built on top of the 
> Parrot Virtual Machine", will leave people going,
>
>   "Huh?!"
>
> I think this is a good reason as anything, to think of getting a visual 
> representation of this, somewhat complicated idea out ASAP.

I agree fully about the need for a visual representation;  as far as
the name goes I'm hoping that people will think of "Rakudo Perl" in
a manner to the way that we currently think of "Strawberry Perl" or
"Vanilla Perl".

> Taking a step back from this soup of ideas and thinking of a logo  
> itself, it seems that it would help to produce something that's made of 
> somewhat interlocking and inter-related pieces: Perl on Parrot has two 
> separate pieces that come together and complete an idea. But there's 
> other things that could take, "Perl's" place, so it's really,
>
>   $x on Parrot
>
> It seems that if a logo would be made, we can modularize, say, that  
> Parrot part and use it for other things - same with the Perl part, if  
> you get into it. 

I can't really speak for what Parrot will want or need, as they already 
have a (very nice) logo.  But having a symbol to represent Parrot in 
the system you propose would likely be very workable.

> What I really *really* need now is some feedback for any and all of the 
> above research and braindump. 

My feedback is essentially "Sounds fantastic!" and I'm eager to see
where it leads.  If I can be of further help, please ask!

Pm


Rakudo Perl development release #14 ("Vienna")

2009-02-26 Thread Patrick R. Michaud
On behalf of the Rakudo development team, I'm pleased to announce
the February 2009 development release of Rakudo Perl #14 "Vienna".
Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
The tarball for the February 2009 release is available from

http://www.pmichaud.com/perl6/rakudo-2009-02.tar.gz

However, because of the rapid pace of Rakudo development and addition
of new features, we still recommend that people wanting to use or work
with Rakudo obtain the latest version directly from the main repository
at github -- more on this in a bit.

This is the fourteenth development release of Rakudo Perl, but it's
the first release independent from Parrot releases.  We will continue
to follow a monthly release cycle, with each release to be code named
after a Perl Mongers group.  This release is named for Vienna.pm
(http://vienna.pm.org), who have been sponsoring Jonathan Worthington's
work on Rakudo since April 2008.  A list of the other planned release
dates and codenames for 2009 is available in the "docs/release_guide.pod"
file.  In general, Rakudo development releases are scheduled to occur
two days after each Parrot monthly release.  Parrot releases the third
Tuesday of each month.

Rakudo Perl now uses git [2] for its version control system, hosted 
at http://github.com/rakudo/rakudo .  The README file there is kept 
up-to-date with the latest instructions for obtaining and building 
Rakudo Perl.

In this release of Rakudo Perl, we've made the following major changes
and improvements:

* Rakudo is now passing 7076 spectests.  This is an increase of 796
  passing tests since the January 2009 release.

* The Configure.pl script supports a "--gen-parrot" option to
  automatically fetch and build the appropriate version of Parrot.

* The default make target now builds a binary executable directly, either
  perl6 or perl6.exe.  It's still a Parrot "fakecutable", but we think
  we've made it more reliable so that it doesn't generate segmentation
  faults on exits.  (If you don't know what a "fakecutable" is you can
  safely ignore this.)

* Many builtins are beginning to be written in pure Perl 6, or Perl 6
  functions with inline PIR.  These builtins are part of the core
  "setting" for Perl 6, and appear in the src/setting/ directory.
  Previously this was known as the "prelude".

* Improved Test.pm diagnostic output.

Also, Rakudo now implements the following Perl 6 features:

* Anonymous classes may be specified using ::
* Existing parameterized roles are now reused instead of creating new ones.
* Roles pun a class when .new is invoked on them.
* "proto" now marks all same-named routines as "multi".
* "XopX" is now "Xop".
* <-> (rw) pointy blocks.
* min= and max= metaoperators.
* Many many bugfixes and documentation improvements.

The development team thanks all of our contributors and sponsors for
making Rakudo Perl possible.  The next release of Rakudo (#15) is
scheduled for March 19, 2009.


References:
[1]  Parrot, http://parrot.org/
[2]  Git version control system, http://git-scm.org/


Re: Rakudo Perl development release #14 ("Vienna")

2009-02-27 Thread Patrick R. Michaud
On Fri, Feb 27, 2009 at 09:07:10PM +, Ross Kendall wrote:
> Thanks for the Vienna release.  All of a sudden Perl 6 feels a lot more
> accessible. 

Yay, that was one of the big goals for the release.

> Are there plans to set up a new website for Rakudo now it's on its own? 
> If so, I would be prepared to offer some Drupal expertise - if it's
> wanted.  I saw mention of a logo before, is there any news on that?

Yes, rakudo.org is currently being revamped to be Drupal-based.
It should be available soon (as in "within the next couple of days").
I'm of the opinion that we should grant authorship access liberally,
because we can use a lot more documentation and support information
for Rakudo Perl.

And yes, we're still in need of a logo of some sort for
Rakudo.  Even an interim logo will be fine for now.  We can 
decide on a much more "official" long-term Rakudo logo as we 
get closer to production releases.

Pm


Rakudo Perl development release #15 ("Oslo")

2009-03-20 Thread Patrick R. Michaud
On behalf of the Rakudo development team, I'm pleased to announce
the March 2009 development release of Rakudo Perl #15 "Oslo".
Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
The tarball for the March 2009 release is available from

http://www.pmichaud.com/perl6/rakudo-2009-03.tar.gz

However, because of the rapid pace of Rakudo development and addition
of new features, we still recommend that people wanting to use or work
with Rakudo obtain the latest version directly from the main repository
at github -- more on this in a bit.

Rakudo Perl follows a monthly release cycle, with each release code named 
after a Perl Mongers group.  This release is named "Oslo" in honor of 
the organizers of the 2009 Nordic Perl Workshop [2], April 16-17, 2009.  
The 2009 Nordic Perl Workshop will have a special focus on Perl 6, 
Rakudo Perl, and Parrot, including Perl 6 tutorials and hackathons 
after the conference itself.

A list of the other planned release dates and codenames for 2009 is 
available in the "docs/release_guide.pod" file.  In general, Rakudo 
development releases are scheduled to occur two days after each 
Parrot monthly release.  Parrot releases the third Tuesday of each month.

Rakudo Perl now uses git [3] for its version control system, hosted 
at http://github.com/rakudo/rakudo .  The README file there is kept 
up-to-date with the latest instructions for obtaining and building 
Rakudo Perl.

In this release of Rakudo Perl, we've made the following major changes
and improvements:

* Rakudo is now passing 7273 spectests.  This is an increase of 197 
  passing tests since the February 2009 release.

* The eval() construct now understands lexical variables from an
  outer scope.

* More of the builtin functions ("settings") are being written in Perl 6.

* Rakudo supports the "R" (reverse) metaoperator.

* Parsing of if, unless, while, until, etc. statements after blocks
  now works correctly.

* The Q quote operator is now implemented, along with several adverbial
  forms.  In particular, the Q:PIR form allows inline PIR to be
  included in Perl 6 code.

* Multi-method dispatch now works with inheritance also.

The development team thanks all of our contributors and sponsors for
making Rakudo Perl possible.  The next release of Rakudo (#16) is
scheduled for April 23, 2009.


References:
[1]  Parrot, http://parrot.org/
[2]  Nordic Perl Workshop 2009, http://www.perlworkshop.no/npw2009/
[3]  Git version control system, http://git-scm.org/


Re: YALI (yet another logo idea)

2009-03-24 Thread Patrick R. Michaud
On Tue, Mar 24, 2009 at 11:29:08AM -0400, Guy Hulbert wrote:
> On Tue, 2009-24-03 at 14:17 +, Ross Kendall wrote:
> > I was thinking that a logo doesn't really need to incorporate a symbol
> > (e.g. camel, onion etc.), and that one of the more important aspects of
> > a logo is the typography.
> > 
> > Rather than ramble on with ideas, I decided to make something to look at:
> > 
> > http://www.rakudo.org/some-rakudo-logo-ideas
> 
> I like 4.

FWIW, I like 4 also.

Pm


Re: Logo considerations

2009-03-24 Thread Patrick R. Michaud
On Tue, Mar 24, 2009 at 10:24:47AM -0700, Larry Wall wrote:
> I want something
> with gut appeal on the order of Tux.  In particular I want a logo
> for Perl 6 that is:
> 
> Fun
> Cool
> Cute
> Named
> Lively
> Punable
> [...]

+2 to this approach.

Pm


Re: Logo considerations - 3 logos needed

2009-03-25 Thread Patrick R. Michaud
On Wed, Mar 25, 2009 at 10:36:56AM -0400, Mark J. Reed wrote:
> Rakudo is a particular implementation of Perl 6 using Parrot.  While
> it is a separate project from both Perl 6 and Parrot, it is intimately
> tied to both, and I think its logo should reflect that. I don't see
> much point in having separate logos for "Rakudo on Parrot" and "Rakudo
> without Parrot".  I mean, I suppose much of the frontend work could be
> ported to a different backend, but would that still be considered
> Rakudo?

I don't know that I consider Rakudo Perl to be forever tied to Parrot.
If we come up with other backends, I'd still consider the result
"Rakudo"; similar to how "Pugs" referred to all of the various backends
available to it and not just the Haskell backend.

So from that perspective, I don't know that the Rakudo logo ought
to be strongly tied to Parrot, any more than we tie the Parrot logo
to the various GNU tools used to build it.

Pm


Oslo Perl 6 Hackathon Notes

2009-04-13 Thread Patrick R. Michaud
As some of you are aware, this week is the Nordic Perl Workshop [1],
and in the days immediately following the workshop we will have
the Oslo Perl 6 Hackathon [2].  During the first day of the hackathon
Gabor Szabo will be doing a "Hands-on Perl 6 training" course [3],
the other two days will be for various hacking tasks (both Perl 6
and Perl 5).

I personally have three goals for my participation at the 
workshop and hackathon:

*  Attend Gabor's course and take careful note of where issues
arise with using Rakudo Perl and/or Perl 6 (including filing
bug reports and/or answering questions as needed).

*  Recruit and encourage people to write Perl 6 programs and
otherwise start hacking on/with Rakudo Perl.

*  Meet with other principal Rakudo and Perl 6 designers and
implementors to plan the next phases of work and address any
significant obstacles currently before us.


For now I've started a page at 
http://www.perlfoundation.org/perl6/index.cgi?perl_6_hackathon_targets
that lists a variety of specific ideas for things to work on
or address at the hackathon.  I'm sure more ideas will arise
at NPW itself, and I invite others to add more items to the
list as well.  Feel free to add things even if you won't be
making it to NPW or the hackathon itself; you may think of something
that we've overlooked, and there are other hackathons planned later
in the summer that will benefit from having the ideas.

Thanks!

Pm

References:
[1] http://www.perlfoundation.org/perl6/index.cgi?oslo_perl_6_hackaton_2009
[2] http://www.perlfoundation.org/perl6/index.cgi?perl_6_hackathon_targets
[3] http://szabgab.com/blog/2009/03/1235863222.html




Rakudo Perl 6 development release #16 ("Bratislava")

2009-04-22 Thread Patrick R. Michaud
On behalf of the Rakudo development team, I'm pleased to announce
the April 2009 development release of Rakudo Perl #16 "Bratislava".
Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
The tarball for the April 2009 release is available from
http://github.com/rakudo/rakudo/downloads .

Due to the continued rapid pace of Rakudo development and the
frequent addition of new Perl 6 features and bugfixes, we continue
to recommend that people wanting to use or work with Rakudo obtain
the latest source directly from the main repository at github.
More details are available at http://rakudo.org/how-to-get-rakudo .

Rakudo Perl follows a monthly release cycle, with each release code named
after a Perl Mongers group.  This release is named "Bratislava",
home to Jonathan Worthington and reportedly an excellent place to
obtain beer (a key component of Jonathan's contributions to Perl).
The Bratislava.pm group is quite active [2], with regular technical
presentations and social gatherings.

In this release of Rakudo Perl, we've made the following major changes
and improvements:

* Rakudo is now passing 10,467 spectests, an increase of 3,194
  passing tests since the March 2009 release.  With this release
  Rakudo is now passing approximately 65% of the available
  spectest suite.

* About 2/3 of the increase in passing tests is due to improved
  Unicode support in Rakudo; constructs such as "\c[LATIN CAPITAL LETTER A]"
  and Unicode character properties in regexes are now supported.

* The prefix:<=> operator is now gone from the Perl 6 specification
  (and thus from Rakudo).  Use .get for reading individual items
  from iterators.

* Rakudo now supports typed arrays and hashes (my Int @array), as
  well as parametric versions of the Associative, Positional,
  and Callable roles, and parametric role subtyping.

* Rakudo now has sockets support (IO::Socket).

* Subroutine return types are now enforced in some cases.

* Rakudo now supports lexical sub declarations.

* Rakudo now supports some P5-style regexes.

* The "quantify-by-separator" feature has been added, so that
  one can write  / [\w+] ** ',' / to get a comma-separated
  list of words.

* More builtin functions and methods have been rewritten in
  Perl 6 and placed as part of the setting.

* Release tar files now contain local copies of the appropriate
  spectests, instead of obtaining checkout copies via Subversion.

* There are additional improvements and features in this release,
  see docs/ChangeLog for a more complete list.

The development team thanks all of our contributors and sponsors for
making Rakudo Perl possible.  If you would like to contribute,
see http://rakudo.org/how-to-help , ask on the perl6-compi...@perl.org
mailing list, or ask on IRC #perl6 on freenode.

The next release of Rakudo (#17) is scheduled for May 21, 2009.
A list of the other planned release dates and codenames for 2009 is
available in the "docs/release_guide.pod" file.  In general, Rakudo
development releases are scheduled to occur two days after each
Parrot monthly release.  Parrot releases the third Tuesday of each month.

Have fun!

References:
[1]  Parrot, http://parrot.org/
[2]  Bratislava.pm, http://bratislava.pm.org/


Rakudo Perl 6 development release #17 ("Stockholm")

2009-05-21 Thread Patrick R. Michaud
On behalf of the Rakudo development team, I'm pleased to announce
the May 2009 development release of Rakudo Perl #17 "Stockholm".
Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
The tarball for the May 2009 release is available from
http://github.com/rakudo/rakudo/downloads .

Due to the continued rapid pace of Rakudo development and the
frequent addition of new Perl 6 features and bugfixes, we continue
to recommend that people wanting to use or work with Rakudo obtain
the latest source directly from the main repository at github.
More details are available at http://rakudo.org/how-to-get-rakudo .

Rakudo Perl follows a monthly release cycle, with each release code named
after a Perl Mongers group.  This release is named "Stockholm";
Stockholm Perl Mongers will be holding a Perl 6 hackathon on May 29 [3].
Perl 6 developer Carl Mäsak is a member of Stockholm Perl Mongers and
a main author of November [4], Druid [5], proto [6], and other
Perl 6-based packages.  Carl also contributes patches to Rakudo,
and has been stress-testing Rakudo over the past year, submitting
nearly 400 bug reports.

In this release of Rakudo Perl, we've made the following major changes
and improvements:

* Rakudo is now passing 11,342 spectests, an increase of 875
  passing tests since the April 2009 release.  With this release
  Rakudo is now passing 68% of the available spectest suite.

* We now have an updated docs/ROADMAP .

* Errors and stack traces now report the file name and line number
  in the original source code.

* Some custom operators can be defined, and it's possible to
  refer to operators using &infix: syntax.

* We can start to load libraries written in other Parrot languages.

* Regexes now produce a Regex sub.

* More builtin functions and methods have been rewritten in
  Perl 6 and placed as part of the setting.

* There are many additional improvements and features in this release,
  see docs/ChangeLog for a more complete list.

The development team thanks all of our contributors and sponsors for
making Rakudo Perl possible.  If you would like to contribute,
see http://rakudo.org/how-to-help , ask on the perl6-compi...@perl.org
mailing list, or ask on IRC #perl6 on freenode.

The next release of Rakudo (#18) is scheduled for June 18, 2009.
A list of the other planned release dates and codenames for 2009 is
available in the "docs/release_guide.pod" file.  In general, Rakudo
development releases are scheduled to occur two days after each
Parrot monthly release.  Parrot releases the third Tuesday of each month.

Have fun!

References:
[1]  Parrot, http://parrot.org/
[2]  Stockholm.pm, http://sthlm.pm.org/
[3]  Stockholm Perl 6 hackathon, 
http://vic20.blipp.com/pipermail/kameler/2009-May/000318.html
[4]  November wiki engine, http://github.com/viklund/november/
[5]  Druid, http://github.com/masak/druid/
[6]  Proto, http://github.com/masak/proto/


Re: Rakudo Perl 6 development release #17 ("Stockholm")

2009-05-26 Thread Patrick R. Michaud
On Sat, May 23, 2009 at 07:33:06PM +0200, Christian Aperghis wrote:
> Reini Urban a écrit :
> > Patrick R. Michaud schrieb:
> >> On behalf of the Rakudo development team, I'm pleased to announce
> >> the May 2009 development release of Rakudo Perl #17 "Stockholm".
> >> Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
> >> The tarball for the May 2009 release is available from
> >> http://github.com/rakudo/rakudo/downloads .
> >
> > Does it finally build and work with installed parrot only?
> 
> On Mac os X 10.5.T the Configure --gen-parrot provides an error in building
> "Stockholm" after having installed the parrot folder.

Could you provide a copy of whatever error you're seeing?
Simply knowing that there's an error doesn't really help us much
in tracking it down.

Pm


Error running parrot_config (was: Rakudo Perl 6 development ...)

2009-05-26 Thread Patrick R. Michaud
On Tue, May 26, 2009 at 10:37:41PM +0100, Nelo Onyiah wrote:
> All I am seeing is just the message:
> 
> Reading configuration information from parrot/parrot_config ...
> Died at Configure.pl line 104.

Okay, this is definitely helpful.

What do you get from manually running "parrot/parrot_config --dump"
from the rakudo/ directory?

Pm


Re: rakudo-current loop 2-3 orders of magnitude slower than perl 5?

2009-06-03 Thread Patrick R. Michaud
On Thu, Jun 04, 2009 at 12:12:06AM +0200, Chris Mair wrote:
> I'm new here, so forgive me if this is not the right list.

You're in the right place!

> After having used perl5 a lot years ago, this weekend I
> finally decieded to have a look at perl6.
> [...]
> Anyway, the parrot and rakudo files were downloaded and
> built in around May 31 22:00, however.
>
> Now, my problem is that perl6 code runs very slooow :(
> [...]
> So, my question: is there something fundamentally
> flawed in how I'm using rakudo (i.e. I'm doing something
> silly), or is this just the state of things at the time
> being?

You're correct, it's very slow.  Incredibly slow.  Slow as in
"There's no way it could possibly be that slow" sort of slow.
That's just the state of things now... but read on.

First, a discussion similar to the example you just gave
came up on use.perl just this past weekend [1,2], and it 
turns out that our implementation of "++" was pathologically 
slow.  So, I fixed that on Monday (June 1st), and things are 
now significantly faster.   (Read the use.perl post for more details):

  [1] http://use.perl.org/~korpenkraxar/journal/39051
  [2] http://use.perl.org/comments.pl?sid=43083&cid=68873

More importantly, it turned out that though many of us felt we
knew where the problem was likely to be, we didn't find the
postfix:<++> issue until I actually did some measurements on it.
That tells us that (1) we need more examples to measure, and
(2) we really need some better measurement tools for Parrot.
We're well aware of the need for #2, and we have some things
in the works to bring resources to bear on that problem.

Now then, just because things are fast*er* as a result of
this fix doesn't mean they're fast yet.  We're still a couple 
of orders of magnitude slower than Perl 5; we know it, we 
don't like it.  But our focus thus far has been more on 
features than speed, because the only good way to optimize
is to test real code, and we can't get a lot of real code
until we have good feature coverage.  But we do have lots of
ideas about where optimizations can still occur, and we get
to them as they become "ripe" for implementation (or when we
discover pathological problems like postfix:<++> above).

To give an idea of the speed at which we're adding optimizations... 
in mid-May it took Rakudo 51 minutes to run the spectest suite on 
my system.  As of this morning it was requiring just over 23 minutes,
and we're running/passing more tests now than we were then.  That's
a better than 50% speed improvement over the span of just 2.5 weeks.

That's also without addressing many of the "deep" performance
issue in Parrot; for example, we know that Parrot's calling conventions
are far slower than they need to be -- those are currently undergoing
a significant refactor, and we expect to see significant speedups 
when those land.

So, it's the state of things today, but I don't expect it to be
the state of things for long into the future.  I don't know when
(if ever) Rakudo will be able to outperform Perl 5 for simple
programs like the one you gave, but I expect that even an
order-of-magnitude difference in speed will be fast enough
for many people to want to use Perl 6 instead of Perl 5.
(And Perl 6 has more opportunities for optimization and customization
than Perl 5 did.)

Thanks for the question and post!

Pm


Rakudo Perl 6 development release #18 ("Pittsburgh")

2009-06-18 Thread Patrick R. Michaud

On behalf of the Rakudo development team, I'm pleased to announce
the June 2009 development release of Rakudo Perl #18 "Pittsburgh".
Rakudo is an implementation of Perl 6 on the Parrot Virtual Machine [1].
The tarball for the June 2009 release is available from
http://github.com/rakudo/rakudo/downloads .

Due to the continued rapid pace of Rakudo development and the
frequent addition of new Perl 6 features and bugfixes, we continue
to recommend that people wanting to use or work with Rakudo obtain
the latest source directly from the main repository at github.
More details are available at http://rakudo.org/how-to-get-rakudo .

Rakudo Perl follows a monthly release cycle, with each release code named
after a Perl Mongers group.  This release is named "Pittsburgh", which
is the host for YAPC|10 (YAPC::NA 2009) [2] and the Parrot Virtual Machine
Workshop [3].  Pittsburgh.pm has also sponsored hackathons for Rakudo 
Perl as part of the 2008 Pittsburgh Perl Workshop [4].

In this release of Rakudo Perl, we've focused our efforts on refactoring
many of Rakudo's internals; these refactors improve performance, 
bring us closer to the Perl 6 specification, operate more cleanly
with Parrot, and provide a stronger foundation for features to be
implemented in the near future.  Some of the specific major changes
and improvements in this release include:

* Rakudo is now passing 11,536 spectests, an increase of 194
  passing tests since the May 2009 release.  With this release
  Rakudo is now passing 68% of the available spectest suite.

* Method dispatch has been substantially refactored; the new dispatcher
  is significantly faster and follows the Perl 6 specification more
  closely.

* Object initialization via the BUILD and CREATE (sub)methods is
  substantially improved.

* All return values are now type checked (previously only explicit
  'return' statements would perform type checking).

* String handling is significantly improved: fewer Unicode-related
  bugs exist, and parsing speed is greatly improved for some programs 
  containing characters in the Latin-1 set.

* The IO .lines and .get methods now follow the specification more closely.

* User-defined operators now also receive some of their associated 
  meta variants.

* The 'is export' trait has been improved; more builtin functions
  and methods can be written in Perl 6 instead of PIR.

* Many Parrot changes have improved performance and reduced overall
  memory leaks (although there's still much more improvement needed).

The development team thanks all of our contributors and sponsors for
making Rakudo Perl possible.  If you would like to contribute,
see http://rakudo.org/how-to-help , ask on the perl6-compi...@perl.org
mailing list, or ask on IRC #perl6 on freenode.

The next release of Rakudo (#19) is scheduled for July 23, 2009.
A list of the other planned release dates and codenames for 2009 is
available in the "docs/release_guide.pod" file.  In general, Rakudo
development releases are scheduled to occur two days after each
Parrot monthly release.  Parrot releases the third Tuesday of each month.

Have fun!

References:
[1]  Parrot, http://parrot.org/
[2]  YAPC|10 http://yapc10.org/yn2009/
[3]  Parrot Virtual Machine Workshop, http://yapc10.org/yn2009/talk/2045
[4]  Pittsburgh Perl Workshop, http://pghpw.org/ppw2008/


  1   2   >