Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Aristotle Pagaltzis
* Elizabeth Mattijsen  [2015-09-26 13:20]:
> The flattening will not be done if more than one argument is specified:
>
> $ 6 'my %h = a => 42, b => 666; my @a = %h,%h; dd @a'
> Array @a = [{:a(42), :b(666)}, {:a(42), :b(666)}]
>
>
> This is the same behaviour as with for:
>
> $ 6 'my %h = a => 42, b => 666; dd $_ for %h'
> :a(42)
> :b(666)
>
> $ 6 'my %h = a => 42, b => 666; dd $_ for %h,%h'
> Hash %h = {:a(42), :b(666)}
> Hash %h = {:a(42), :b(666)}
>
>
> It’s the same rule throughout  :-)

Yes, but adding a trailing comma to convert a lone item to an element in
a one-element list, causing the flattening to apply to the list instead
of the item, thus avoiding the flattening of that item as a side effect
of sorts… is just way too meta for my taste, at least for everyday parts
of the language.

> There is: you just need to itemize the hash, e.g. by prefixing it with $
>
> $ 6 'my %h = a => 42, b => 666; my @a = $%h; dd @a'
> Array @a = [{:a(42), :b(666)},]
>
> This is the one argument rule at work.

Aha! Much better. Explicit. “Don’t subject %h to flattening.”

No need to combine two other unrelated rules to bend around invoking the
undesired rule; just directly saying not to invoke it.

Now of course I must ask – is there an opposite also? I.e. when writing
a list, is there a way I can say “do flatten this item?” Or put in other
words, what goes in place of XXX in the following to make it real?

$ 6 'my %h = a => 42, b => 666; dd $_ for %h,XXX'
Hash %h = {:a(42), :b(666)}
:a(42)
:b(666)

Regards,
-- 
Aristotle Pagaltzis // 


Re: Method 'send' not found for invocant of class 'IO::Socket::INET'

2015-09-26 Thread Gabor Szabo
Tobias thanks!

I ran panda install HTTP::Easy
and it installed the new version in
/Users/gabor/rakudo-star-2015.09/install/share/perl6/site/lib/HTTP/Easy.pm6

but Rakudo is still loading the old one from

/Users/gabor/rakudo-star-2015.09/install/share/perl6/lib/HTTP/Easy.pm6

and crashing.

I can run

perl6 -I /Users/gabor/rakudo-star-2015.09/install/share/perl6/site/lib/
examples/app.pl

and then it works, but is there something else I should have done to make
rakudo look
for the site module before the one in the old place or to let panda install
over the top of
the old version? Oh and there is also a  .moarvm version of the file.

regards
  Gabor


On Sat, Sep 26, 2015 at 3:37 PM, Tobias Leich  wrote:

> You need to upgrade HTTP::Easy, it already contains a fix.
>
>
> Am 26.09.2015 um 12:26 schrieb Gabor Szabo:
>
> And just to clarify launching this simple script (and then accessing it
> via a browser) would show the same problem:
>
> use lib 'lib';
>
> use Bailador;
>
> get '/' => sub {
> "hello world"
> }
>
> baile;
>
>
> On Sat, Sep 26, 2015 at 1:16 PM, Gabor Szabo  wrote:
>
>> In the cloned repository of Bailador I ran
>>
>> perl6 examples/app.pl
>>
>> It launched the web server printing
>>
>> Entering the development dance floor: 
>> http://0.0.0.0:3000
>> [2015-09-26T10:04:46Z] Started HTTP server.
>>
>> but when I tried to access it with a browser it crashed with:
>>
>> [2015-09-26T10:04:49Z] GET / HTTP/1.1
>> Method 'send' not found for invocant of class 'IO::Socket::INET'
>>   in method run at
>> /Users/gabor/rakudo-star-2015.09/install/share/perl6/lib/HTTP/Easy.pm6:193
>>   in sub baile at /Users/gabor/work/Bailador/lib/Bailador.pm:153
>>   in block  at examples/app.pl:38
>>
>>
>> Any idea what's this and how to fix it?
>>
>> Oh and I found the INET module here:
>> /Users/gabor/rakudo-star-2015.09//rakudo/src/core/IO/Socket/INET.pm
>> it does not even seem to be "installed".
>>
>>
>> regards
>> Gabor
>>
>>
>
>


Re: Method 'send' not found for invocant of class 'IO::Socket::INET'

2015-09-26 Thread Gabor Szabo
And just to clarify launching this simple script (and then accessing it via
a browser) would show the same problem:

use lib 'lib';

use Bailador;

get '/' => sub {
"hello world"
}

baile;


On Sat, Sep 26, 2015 at 1:16 PM, Gabor Szabo  wrote:

> In the cloned repository of Bailador I ran
>
> perl6 examples/app.pl
>
> It launched the web server printing
>
> Entering the development dance floor: http://0.0.0.0:3000
> [2015-09-26T10:04:46Z] Started HTTP server.
>
> but when I tried to access it with a browser it crashed with:
>
> [2015-09-26T10:04:49Z] GET / HTTP/1.1
> Method 'send' not found for invocant of class 'IO::Socket::INET'
>   in method run at
> /Users/gabor/rakudo-star-2015.09/install/share/perl6/lib/HTTP/Easy.pm6:193
>   in sub baile at /Users/gabor/work/Bailador/lib/Bailador.pm:153
>   in block  at examples/app.pl:38
>
>
> Any idea what's this and how to fix it?
>
> Oh and I found the INET module here:
> /Users/gabor/rakudo-star-2015.09//rakudo/src/core/IO/Socket/INET.pm
> it does not even seem to be "installed".
>
>
> regards
> Gabor
>
>


Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Tobias Leich
Itemization helps:

m: my %h = x => 6, y => 7; my @a = $%h; say @a[0]
rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤»

m: my %h = x => 6, y => 7; my @a; @a.push: $%h; say @a[0]
rakudo-moar 0132b6: OUTPUT«x => 6, y => 7␤»

Am 26.09.2015 um 07:58 schrieb Gabor Szabo:
> In the first two cases the hash was converted to Pairs before
> assigning to the array.
> Only the third case gave what I hoped for. How can I push a hash onto
> an array as a single entity?
>
>
> use v6;
>
> my %h = x => 6, y => 7;
> say %h.perl; #  {:x(6), :y(7)}
>
> my @a = %h;
> say @a.elems;   #
> say @a[0]; # x => 6
>
>
>
> my @c;
> @c.push(%h);
> say @c.elems; # 2
> say @c[0];   # x => 6
>
>
> my @b;
> @b[@b.elems] = %h;
> say @b.elems;  # 1
> say @b[0];# x => 6, y => 7
>
>



Re: require on string stopped working in rakudo 2015.09

2015-09-26 Thread Moritz Lenz
Hi,

On 09/26/2015 06:47 AM, Gabor Szabo wrote:
> Hi,
> 
> I am really glad Rakudo finally came out.
> I've installed in and tried to run the tests of Perl6::Maven.
> 
> They quickly failed as I have been using 'require' on string
> to check if all the module compile properly.
> 
> The following code now fails:
> 
> use v6;
> my $name = 'Bailador';
> require $name;
> 
> 
> even though
> 
> require Bailador;
> 
> works.
> 
> In 2015.07 both worked.

I stumbled across the same thing in DBIish, and was told that the proper
way to require a module name (and not a file name) is

require ::($name);

which does work in 2015.09.

I guess there's no deprecation, because it was only an accident that the
string form worked before.

Cheers,
Moritz


Method 'send' not found for invocant of class 'IO::Socket::INET'

2015-09-26 Thread Gabor Szabo
In the cloned repository of Bailador I ran

perl6 examples/app.pl

It launched the web server printing

Entering the development dance floor: http://0.0.0.0:3000
[2015-09-26T10:04:46Z] Started HTTP server.

but when I tried to access it with a browser it crashed with:

[2015-09-26T10:04:49Z] GET / HTTP/1.1
Method 'send' not found for invocant of class 'IO::Socket::INET'
  in method run at
/Users/gabor/rakudo-star-2015.09/install/share/perl6/lib/HTTP/Easy.pm6:193
  in sub baile at /Users/gabor/work/Bailador/lib/Bailador.pm:153
  in block  at examples/app.pl:38


Any idea what's this and how to fix it?

Oh and I found the INET module here:
/Users/gabor/rakudo-star-2015.09//rakudo/src/core/IO/Socket/INET.pm
it does not even seem to be "installed".


regards
Gabor


Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Aristotle Pagaltzis
* Moritz Lenz  [2015-09-26 09:40]:
> A trailing comma helps:
>
> my %h = a => 1, b => 2;
> my @a = %h, ;
> say @a.perl;# [{:a(1), :b(2)},]

I think I understand why, but wow, that’s not reasonable. Is there
really no better way to avoid the flattening? Even Perl 5 is nicer
in that situation…

-- 
Aristotle Pagaltzis // 


Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Elizabeth Mattijsen
> On 26 Sep 2015, at 13:09, Aristotle Pagaltzis  wrote:
> * Moritz Lenz  [2015-09-26 09:40]:
>> A trailing comma helps:
>> 
>> my %h = a => 1, b => 2;
>> my @a = %h, ;
>> say @a.perl;# [{:a(1), :b(2)},]
> 
> I think I understand why, but wow, that’s not reasonable. Is there
> really no better way to avoid the flattening? Even Perl 5 is nicer
> in that situation…

There is: you just need to itemize the hash, e.g. by prefixing it with $

$ 6 'my %h = a => 42, b => 666; my @a = $%h; dd @a'
Array @a = [{:a(42), :b(666)},]

This is the one argument rule at work.


The flattening will not be done if more than one argument is specified:

$ 6 'my %h = a => 42, b => 666; my @a = %h,%h; dd @a'
Array @a = [{:a(42), :b(666)}, {:a(42), :b(666)}]


This is the same behaviour as with for:

$ 6 'my %h = a => 42, b => 666; dd $_ for %h'
:a(42)
:b(666)

$ 6 'my %h = a => 42, b => 666; dd $_ for %h,%h'
Hash %h = {:a(42), :b(666)}
Hash %h = {:a(42), :b(666)}


It’s the same rule throughout  :-)


Liz

Re: require on string stopped working in rakudo 2015.09

2015-09-26 Thread Elizabeth Mattijsen
> On 26 Sep 2015, at 06:47, Gabor Szabo  wrote:
> I am really glad Rakudo finally came out.
> I've installed in and tried to run the tests of Perl6::Maven.
> 
> They quickly failed as I have been using 'require' on string
> to check if all the module compile properly.
> 
> The following code now fails:
> 
> use v6;
> my $name = 'Bailador';
> require $name;
> 
> 
> even though
> 
> require Bailador;
> 
> works.
> 
> In 2015.07 both worked.
> 
> 
> I've fixed my script by switching to EVAL "use $module";
> but I wonder if this is a regression or a planned deprecation?

I’m not sure yet.

Could you please rakudobug it so that it doesn’t fall through the cracks?  This 
change did not fire any spectest alarm either, so maybe we need a test for it 
as well  :-)



Liz

Re: require on string stopped working in rakudo 2015.09

2015-09-26 Thread Moritz Lenz

On 09/26/2015 01:07 PM, Elizabeth Mattijsen wrote:
>> On 26 Sep 2015, at 06:47, Gabor Szabo  wrote:
>> I am really glad Rakudo finally came out.
>> I've installed in and tried to run the tests of Perl6::Maven.
>> 
>> They quickly failed as I have been using 'require' on string
>> to check if all the module compile properly.
>> 
>> The following code now fails:
>> 
>> use v6;
>> my $name = 'Bailador';
>> require $name;
>> 
>> 
>> even though
>> 
>> require Bailador;
>> 
>> works.
>> 
>> In 2015.07 both worked.
>> 
>> 
>> I've fixed my script by switching to EVAL "use $module";
>> but I wonder if this is a regression or a planned deprecation?
> 
> I’m not sure yet.
> 
> Could you please rakudobug it so that it doesn’t fall through the cracks?  
> This change did not fire any spectest alarm either, so maybe we need a test 
> for it as well  :-)

I've opened https://rt.perl.org/Ticket/Display.html?id=126096 and later
rejcted it when learning about the desired behavior.

Cheers,
Moritz


Re: Method 'send' not found for invocant of class 'IO::Socket::INET'

2015-09-26 Thread Moritz Lenz
Hi,

method .send was deprecated in favor of .print (for strings) and .write
(with bufs/blobs)

Maybe Bailador or one of its dependencies needs updating.

Cheers,
Moritz


Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Moritz Lenz

On 09/26/2015 02:26 PM, Aristotle Pagaltzis wrote:
> Now of course I must ask – is there an opposite also? I.e. when writing
> a list, is there a way I can say “do flatten this item?” 

Yes, that's what type Slip is for: http://doc.perl6.org/type/Slip

It's useful for returning more than one list item from a .map call, for
example.

Cheers,
Moritz


Re: Method 'send' not found for invocant of class 'IO::Socket::INET'

2015-09-26 Thread Tobias Leich
You need to upgrade HTTP::Easy, it already contains a fix.

Am 26.09.2015 um 12:26 schrieb Gabor Szabo:
> And just to clarify launching this simple script (and then accessing
> it via a browser) would show the same problem:
>
> use lib 'lib';
>
> use Bailador;
>
> get '/' => sub {
> "hello world"
> }
>
> baile;
>
>
> On Sat, Sep 26, 2015 at 1:16 PM, Gabor Szabo  > wrote:
>
> In the cloned repository of Bailador I ran
>
> perl6 examples/app.pl 
>
> It launched the web server printing
>
> Entering the development dance floor: http://0.0.0.0:3000
> [2015-09-26T10:04:46Z] Started HTTP server.
>
> but when I tried to access it with a browser it crashed with:
>
> [2015-09-26T10:04:49Z] GET / HTTP/1.1
> Method 'send' not found for invocant of class 'IO::Socket::INET'
>   in method run at
> /Users/gabor/rakudo-star-2015.09/install/share/perl6/lib/HTTP/Easy.pm6:193
>   in sub baile at /Users/gabor/work/Bailador/lib/Bailador.pm:153
>   in block  at examples/app.pl:38 
>
>
> Any idea what's this and how to fix it?
>
> Oh and I found the INET module here:
> /Users/gabor/rakudo-star-2015.09//rakudo/src/core/IO/Socket/INET.pm
> it does not even seem to be "installed".
>
>
> regards
> Gabor
>
>



signatures, multi and named arguments

2015-09-26 Thread mt1957
I was wondering if the long name of sub/method/submethod also includes 
the named arguments to differentiate between multi's. I had problems 
using multi on  BUILD submethods which only accept named arguments. The 
dispather (also with other named methods) always takes the first method 
of the multi's and doesn't choose the proper one looking at the named 
arguments.


Is this behavior correct?

For the moment I can get by using callsame after doing tests on the 
arguments.


perl6 version 2015.09-95-g3970634 built on MoarVM version 
2015.09-35-gd15a446


Greetings
Marcel Timmerman



Re: How to push a hash on an array without flattening it to Pairs?

2015-09-26 Thread Elizabeth Mattijsen
> On 26 Sep 2015, at 14:26, Aristotle Pagaltzis  wrote:
> * Elizabeth Mattijsen  [2015-09-26 13:20]:
>> There is: you just need to itemize the hash, e.g. by prefixing it with $
>> 
>> $ 6 'my %h = a => 42, b => 666; my @a = $%h; dd @a'
>> Array @a = [{:a(42), :b(666)},]
>> 
>> This is the one argument rule at work.
> 
> Aha! Much better. Explicit. “Don’t subject %h to flattening.”
> 
> No need to combine two other unrelated rules to bend around invoking the
> undesired rule; just directly saying not to invoke it.
> 
> Now of course I must ask – is there an opposite also? I.e. when writing
> a list, is there a way I can say “do flatten this item?” Or put in other
> words, what goes in place of XXX in the following to make it real?
> 
>$ 6 'my %h = a => 42, b => 666; dd $_ for %h,XXX'
>Hash %h = {:a(42), :b(666)}
>:a(42)
>:b(666)

moritz++ already mentioned it:

$ 6 'my %h = a => 42, b => 666; dd $_ for |%h,|%h'
:a(42)
:b(666)
:a(42)
:b(666)

Prefix | is a short way to Slip something :-)



Liz

Re: require on string stopped working in rakudo 2015.09

2015-09-26 Thread Gabor Szabo
On Sat, Sep 26, 2015 at 3:39 PM, Moritz Lenz  wrote:

>
> >> I've fixed my script by switching to EVAL "use $module";
> >> but I wonder if this is a regression or a planned deprecation?
> >
> > I’m not sure yet.
> >
> > Could you please rakudobug it so that it doesn’t fall through the
> cracks?  This change did not fire any spectest alarm either, so maybe we
> need a test for it as well  :-)
>
> I've opened https://rt.perl.org/Ticket/Display.html?id=126096 and later
> rejcted it when learning about the desired behavior.
>
>

Thanks for all the replies. I stick with EVAL for now.

BTW  http://doc.perl6.org/ does not know about 'require' at all.   (nor
seems to know about 'use'). nor EVAL.

Gabor


Announce: Rakudo Star Release 2015.09

2015-09-26 Thread Moritz Lenz
On behalf of the Rakudo and Perl 6 development teams, I'm excited to
announce the September 2015 release of "Rakudo Star", a useful and
usable distribution of Perl 6. The tarball for the September 2015
release is available from .

This Rakudo Star release comes with support for the MoarVM backend (all
module tests pass on supported platforms).
Please note that this release of Rakudo Star is not fully functional
with the JVM backend from the Rakudo compiler. Support should be
restored shortly.

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 2015.09] of the [Rakudo Perl 6
compiler], version 2015.09 of [MoarVM], plus various modules,
documentation, and other resources collected from the Perl 6 community.

[release 2015.09]:
https://github.com/rakudo/rakudo/blob/nom/docs/announce/2015.09.md
[Rakudo Perl 6 compiler]: http://github.com/rakudo/rakudo
[MoarVM]: http://moarvm.org/

Some of the new compiler features added to this release include:

* Great List Refactor (GLR) - See http://design.perl6.org/S07.html
* All Deprecations removed in preparation for Christmas release
* Added support for calling into C++ libraries and calling methods on
C++ classes
* New slurpy parameter, +args or +@args, to allow for one-argument style
binding
* New with/orwith/without conditionals allow you to check for .defined
but topicalize to the actual value returned
* New `supply`, `whenever` and `react` blocks for easy reactive programming
* All Unicode digits can now be part of literal numbers
* `val()` and allomorphic types implemented
* Most European quoting styles are now supported
* New $[...] and ${...} constructs allow prefix itemization
* The .gist and .perl methods can now deal with self-referential structures


Notable changes in modules shipped with Rakudo Star:

* All modules fixed to work with GLR where needed
* Panda now includes JSON::Fast and no longer precompiles to byte code
* Terminal::ANSIColor replaces the deprecated Term::ANSIColor
* New Perl 6 tutorial replaces original perl6 book draft

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
  * non-blocking I/O (in progress)
  * much of Synopsis 9 and 11

There is an online resource at 
that lists the known implemented and missing features of Rakudo's
backends 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
Perl 6 tutorial is available as docs/2015-spw-perl6-course.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.