Re: [perl #132316] AutoReply: [Double Free] Crash while running program

2017-10-31 Thread mt1957 via RT
On 10/17/2017 08:37 PM, perl6 via RT wrote:

I've modified the BSON code quite a bit thanks to examples from Zoffix, 
crashes are gone! Also I changed the parts encoding the document due to 
hangups I still experienced. This was still a problem of which I thought 
I had fixed it, issue #20 threadpool exhaustion 
*
*
Hangups did still occur after that but it went when I upgraded rakudo. 
(version 2017.10-25-gbaed02bf7 built on MoarVM version 2017.10)

I've tested for hours with the

while prove -e perl6 t; do true; done

trick. So I think this ticket can be closed.

Regards,
Marcel


Re: [perl #132316] [SEGV] Crash while running program (MongoDB module)

2017-10-28 Thread mt1957 via RT
Hi @Zoffix Znet

Do you have any pointers or howto's to write thread-save code? Otherwise 
I'd remove all of the promises. It gave some other problems in the past.
Regards
Marcel
> On Thu, 26 Oct 2017 06:04:51 -0700, alex.jakime...@gmail.com wrote:
>> FWIW, when toasting I observed double free or corruption when
>> installing both
>> BSON and MongoDB modules. The issue is really there, and should be
>> reproducible
>> by just running the tests. That said, I've been running BSON tests
>> locally in a
>> loop for hours with no luck.
> I can repro it easily on by Ubuntu box. Golfed it down to the attached code 
> running in BSON repo[^1]
> checkout with `while perl6 -Ilib t/300-document.t; do true; done`. I get 
> double-free errors as well as
> occasional failing tests.
>
> Briefly glancing at the guts of the module and seeing all the Promises 
> created left, right, and center,
> it wouldn't surprise me if this issue is due to the BSON module doing 
> thread-unsafe things somewhere and
> not an issue in rakudo.
>
> [1] https://github.com/MARTIMM/BSON
>


Re: [perl #132316] [Double Free] Crash while running program

2017-10-18 Thread mt1957 via RT
On 10/17/2017 09:27 PM, Timo Paulssen via RT wrote:
> if you can, please re-compile MoarVM passing the same options that were
> used before (you can find them on the first screenfuls of the Makefile
> inside moarvm's source folder) to Configure.pl but also include
> --debug=3 and --optimize=0. This is an optional step. After that, please
> run perl6-valgrind-m instead of perl6 or perl6-m to execute your script,
> that should give more helpful data.
>
> Later on, to run stuff regularly again, turn optimize back up to 3,
> otherwise things will be noticeably slower.
>
@timo

The program didn't crash but the system got slower until a point that I 
had to stop it. The end result is shown below. (There are 2 more runs 
below this one!)


==26702==
==26702== Process terminating with default action of signal 2 (SIGINT)
==26702==    at 0x5DE090B: pthread_cond_wait@@GLIBC_2.3.2 (in 
/usr/lib64/libpthread-2.25.so)
==26702==    by 0x51061F8: uv_cond_wait (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x5061E04: shift (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x50419F3: MVM_repr_shift_o (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x5091898: worker (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x5019EF0: thread_initial_invoke (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x4FF84F7: MVM_interp_run (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x5019F6D: start_thread (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==26702==    by 0x5DDA36C: start_thread (in /usr/lib64/libpthread-2.25.so)
==26702==
==26702== HEAP SUMMARY:
==26702== in use at exit: 491,357,261 bytes in 1,627,986 blocks
==26702==   total heap usage: 29,576,790 allocs, 27,948,804 frees, 
17,354,627,753 bytes allocated
==26702==
==26702== LEAK SUMMARY:
==26702==    definitely lost: 1,213,140 bytes in 37,380 blocks
==26702==    indirectly lost: 49,224 bytes in 1,709 blocks
==26702==  possibly lost: 395,844 bytes in 7,003 blocks
==26702==    still reachable: 489,699,053 bytes in 1,581,894 blocks
==26702== suppressed: 0 bytes in 0 blocks
==26702== Rerun with --leak-check=full to see details of leaked memory
==26702==
==26702== For counts of detected and suppressed errors, rerun with: -v
==26702== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)



A run on a smaller set of files and directories ended like this

==27745==
==27745== HEAP SUMMARY:
==27745== in use at exit: 299,554,654 bytes in 996,179 blocks
==27745==   total heap usage: 3,885,468 allocs, 2,889,289 frees, 
2,080,116,257 bytes allocated
==27745==
==27745== LEAK SUMMARY:
==27745==    definitely lost: 632,860 bytes in 19,779 blocks
==27745==    indirectly lost: 15,392 bytes in 436 blocks
==27745==  possibly lost: 381,904 bytes in 6,792 blocks
==27745==    still reachable: 298,524,498 bytes in 969,172 blocks
==27745== suppressed: 0 bytes in 0 blocks
==27745== Rerun with --leak-check=full to see details of leaked memory
==27745==
==27745== For counts of detected and suppressed errors, rerun with: -v
==27745== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)


Then I ran with the option '--leak-check=full' which ended with a much 
larger list of data

==27960==
==27960== HEAP SUMMARY:
==27960== in use at exit: 280,544,350 bytes in 992,192 blocks
==27960==   total heap usage: 3,672,304 allocs, 2,680,112 frees, 
1,929,387,061 bytes allocated
==27960==
==27960== 24 bytes in 3 blocks are possibly lost in loss record 820 of 4,825
==27960==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==27960==    by 0x50941CD: plan_for_cs (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x50942FB: plan_for_sf (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x50944CF: MVM_spesh_plan (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x5091A13: worker (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x5019EF0: thread_initial_invoke (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x4FF84F7: MVM_interp_run (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x5019F6D: start_thread (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x5DDA36C: start_thread (in /usr/lib64/libpthread-2.25.so)
==27960==
==27960== 81 bytes in 27 blocks are definitely lost in loss record 1,626 
of 4,825
==27960==    at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
==27960==    by 0x509779D: MVM_string_ascii_encode_substr (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x5097BF5: MVM_string_ascii_encode (in 
/home/marcel/Software/perl6/rakudo/install/lib/libmoar.so)
==27960==    by 0x50BA5DD: MVM_unicode_name_to_property_value_c

Re: [perl #132316] [Double Free] Crash while running program

2017-10-18 Thread mt1957 via RT
@Aleks-Daniel Jakimenko-Aleksejev
> How can I reproduce this issue? What code did you use?
>
Well,

1) Install a mongod server and start it up. Its address  might be 
127.0.0.1:27017 which is the default for mongod servers. Servers can be 
downloaded using

$ curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.9.tgz

When unpacked, you can find the server in the bin directory.

2) Install MongoDB. it depends on a host of modules.

3) Install the Library project from github; 
https://github.com/MARTIMM/Library

4) Setup a config file in $HOME/.library/config.toml

database = "Library"
uri = "mongodb://127.0.0.1:27017"
[collection]
meta-config = "Metaconfig"
meta-data = "Metadata"

5) Run the program (take a directory which is not of value for you to be 
sure! like /tmp)

$ store-file-metadata.pl6 fs -et -r 

If the directory is sufficiently large/deep, the program will crash.


I can imagine that this will take too much to do, thanks anyway if you try.

Marcel


Re: [perl #131780] [Double Free] Crash while running test

2017-07-22 Thread mt1957 via RT
On 07/22/2017 12:03 PM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote:
> Is there any code snippet to reproduce it?
>
> The backtrace mentions mongo-perl6-driver…
True, its in the mongodb driver project. The test is in the attachment 
and it crashed around line
98 or 99. Just finished the 'Find tests' and done the first test of 
'Count tests' subtest. These few lines were visible just before the crash;


...
 ok 10 - Key '_id' does not exist
 ok 11 - Key 'code' does not exist
 ok 12 - Key 'name' exists
 ok 13 - Key 'address' exists
 ok 14 - Key 'city' exists
 1..14
ok 2 - Find tests
 ok 1 - 200 records
... crash ...


  The difficulty is that it crashed once but it didn't after repeated 
tests of the same code.


use v6;

use lib 't';

use Test;
use Test-support;

use MongoDB;
use MongoDB::Client;
use MongoDB::Cursor;
use BSON::ObjectId;
use BSON::Document;

#---
drop-send-to('mongodb');
drop-send-to('screen');
#modify-send-to( 'screen', :level(MongoDB::MdbLoglevels::Trace));
info-message("Test $?FILE start");

my MongoDB::Test-support $ts .= new;

my MongoDB::Client $client = $ts.get-connection;
my MongoDB::Database $database = $client.database('test');
my MongoDB::Collection $collection = $database.collection('testf');
my BSON::Document $req;
my BSON::Document $doc;
my MongoDB::Cursor $cursor;

#--
subtest 'setup database', {

  $database.run-command: (dropDatabase => 1,);

  # Insert many documents to see proper working of get-more docs request
  # using wireshark
  #
  my Array $docs = [];

  for ^200 -> $i {
$docs.push: (
  code=> 'd1',
  name=> 'name and lastname',
  address => 'address',
  city=> 'new york',
  test_record => "tr$i"
);
  }

  $req .= new: (
insert => $collection.name,
documents => $docs
  );

  $doc = $database.run-command($req);

  is $doc, 1, 'insert ok';
  is $doc, 200, 'inserted 200 docs';

  # Request to get all documents listed to generate a get-more request
  $cursor = $collection.find(
:criteria(test_record => 'tr100',),
:projection(_id => 0,)
  );

  $doc = $cursor.fetch;
  is $doc.elems, 5, '5 fields in record, _id not returned';
  is $doc, 'tr100', 'test record 100 found';
}

#--
subtest "Find tests", {

  check-document(
( code => 'd1', test_record => 'tr3'),
( _id => 1, code => 1, name => 1, 'some-name' => 0)
  );

  check-document(
( code => 'd1', test_record => 'tr4'),
( _id => 1, code => 1, name => 0, address => 0, city => 0),
( code => 1,)
  );

  check-document(
( code => 'd1', test_record => 'tr5'),
( _id => 0, code => 0, name => 1, address => 1, city => 1),
( _id => 0, code => 0)
  );
}

#--
subtest "Count tests", {

  $req .= new: ( count => $collection.name);
  $doc = $database.run-command($req);
  is $doc, 200, '200 records';

  $req = ( code => 'd1', test_record => 'tr3');
  $doc = $database.run-command($req);
  is $doc, 1, '1 record';

  $req = ();
  $req = 3;
  $doc = $database.run-command($req);
  is $doc, 3, '3 records with limit';

  $req = ();
  $req = 3;
  $req = 198;
  $doc = $database.run-command($req);
  is $doc, 2, '2 records using skip and limit';
}

#---
subtest "Testing explain and performance using cursor", {

  # The server needs to scan through all documents to see if the query matches
  # when there is no index set.
  $req .= new: (
explain => (
  find => 'testf',
  filter => (test_record => 'tr38'),
  options => ()
),
verbosity => 'executionStats'
  );

  $doc = $database.run-command($req);
  my $s = $doc;
  is $s, 1, 'One doc found';
  is $s, 200, 'Scanned 200 docs, bad searching';

  # Now set an index on the field and the scan goes only through one document
  $doc = $database.run-command: (
createIndexes => $collection.name,
indexes => [ (
key => (test_record => 1,),
name => 'tf_idx',
  ),
]
  );

  is $doc, False, 'Not created automatically';
  is $doc, 1, 'Only 1 index before call';
  is $doc, 2, 'Now there are 2';

  $doc = $database.run-command($req);
  $s = $doc;
  is $s, 1, 'One doc found';
  is $s, 1, 'Scanned 1 doc, great searching';
}

#---
subtest "Testing explain and performance using hint", {

  # Give a bad hint and get explaination(another possibility from above
  # explain using find in stead of run-command)
  $cursor = $collection.find(
:criteria(
  '$query' => (test_record => 'tr38',),
  '$hint' => (_id => 1,),
  '$explain' => 1
),

Re: [perl #131493] changed type of variable

2017-06-03 Thread mt1957 via RT
After some discussion I've understood that I have to do some homework 
and that this bug can be closed. Thanks Jnhtn and Araraloren for your help

Regards,
Marcel


Re: [perl #131493] changed type of variable

2017-06-03 Thread mt1957 via RT
On 06/03/2017 11:36 AM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote:
> sub s (Str() :$str) {say $str.WHAT}; s(:str<1>) # IntStr
> sub s (Str :$str) {say $str.Str.WHAT}; s(:str<1>) # Str

I think the last one is coerced explicitly. Btw I didn't know about 
'Str() :$str' specification. What does it do?


The previous mail about the type test 'say Str ~~ IntStr' I meant that 
this is the test what the coercion to Str should force isn't it?

Marcel


Re: [perl #131493] changed type of variable

2017-06-03 Thread mt1957 via RT
On 06/03/2017 11:36 AM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote:
> say IntStr ~~ Str

 > say Str ~~ IntStr
False


Re: [perl #131242] Bug IO::Path method move

2017-05-02 Thread mt1957 via RT
Thanks very much
Marcel


dies-ok can return ok on everything dying

2017-04-18 Thread mt1957

Hi,

I've encountered a little problem using dies-ok() from the Test module;

The case was that I made an error within the block used as the first 
argument to dies-ok. In that particular case the perl6 compiler hurled 
an exception and dies-ok accepted it as an ok action which was not ok 
because the real test was not performed.


I have reverted to the try/catch methods I used before because I can 
then test the

exception object in $_ for its type and message.

Perhaps dies-ok could be extended to do these test for me, testing any 
field in the object available. Something like;
dies-ok {... test ... }, '...description...', :name<...exception object 
name...>, :message<...>;


where :name tests the exception object for its name(.^name) and :message 
tests the payload of the object by calling the message method when 
available. Maybe some other less common methods of the exception object 
can be tested this way. The named attributes can be optional to revert 
to old behaviour.


The code below can also be found at 
https://gist.github.com/MARTIMM/747ccf562b18e42235efe7623673978d


use v6;
use Test;
#--
d-ok( {die 'oh oh 0';}, 'oh oh 0');
d-ok( {die 'oh oh 1';}, 'oh oh 1', :name);
d-ok( {die 'oh oh 2';}, 'oh oh 2', :message);
d-ok( {die 'oh oh 3';}, 'oh oh 3', :name, :message );
d-ok( {die 'oh oh 4';}, 'oh oh 4', :name, :message(/ '4' $/) );

# Dies without knowing that the method Lisp does not exist!
d-ok( {'oh oh 5'.split('o').Lisp;}, 'oh oh 5');

# When :message or :name is used the result would fail showing a modified 
description
d-ok( {'oh oh 6'.split('o').Lisp;}, 'oh oh 6', :name);

# Other examples with mistakes in what the name or messages should be
d-ok( {die 'oh oh 7';}, 'oh oh 7', :name);
d-ok( {die 'oh oh 8';}, 'oh oh 8', :message);
d-ok( {die 'oh oh 9';}, 'oh oh 9', :name, :message(/ '4' $/) );

#--
# alternative dies-ok. Returns a list which must be flattened to be used with 
(n)ok.
# :message can be a string or regex. name and message are optional.
sub d-ok ( Code:D $code, Str $description is copy, Str :$name, :$message ) {

  my Bool $dies-ok = False;

  try {
$code();

CATCH {
  default {
$dies-ok = True;

if ? $name {
  $dies-ok = .^name eq $name;
  $description = .^name ~ ': ' ~ .message unless $dies-ok;
}

if $dies-ok and $message ~~ Str and ? $message {
  $dies-ok = .message() eq $message;
  $description = .^name ~ ': ' ~ .message unless $dies-ok;
}

if $dies-ok and $message ~~ Regex {
  $dies-ok = ?(.message() ~~ $message);
  $description = .^name ~ ': ' ~ .message unless $dies-ok;
}
  }
}
  }

  ok $dies-ok, $description;
}

#--
done-testing;


Giving the following results;


prove6 -v t/dies-ok.t

t/dies-ok.t ..
ok 1 - oh oh 0
ok 2 - oh oh 1
ok 3 - oh oh 2
ok 4 - oh oh 3
ok 5 - oh oh 4
ok 6 - oh oh 5
not ok 7 - X::Method::NotFound: No such method 'Lisp' for invocant of type 'Seq'

# Failed test 'X::Method::NotFound: No such method 'Lisp' for invocant of type 
'Seq''
# at t/100-fromfile.t line 90
not ok 8 - X::AdHoc: oh oh 7

# Failed test 'X::AdHoc: oh oh 7'
# at t/100-fromfile.t line 90
not ok 9 - X::AdHoc: oh oh 8

# Failed test 'X::AdHoc: oh oh 8'
# at t/100-fromfile.t line 90
not ok 10 - X::AdHoc: oh oh 9

# Failed test 'X::AdHoc: oh oh 9'
# at t/100-fromfile.t line 90
1..10
# Looks like you failed 4 tests of 10
Dubious, test returned 4 (wstat 1024, 0x400)
Failed 4/10 subtests

Test Summary Report
---
t/dies-ok.t (Wstat: 1024 Tests: 10 Failed: 4)
  Failed tests:  7-10
  Non-zero exit status: 4
Files=1, Tests=10,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.30 cusr  0.02 
csys =  0.34 CPU)
Result: FAIL

The last 4 descriptions are changed by the sub to make it clear that the 
exception name and/or message are different. Note that test 6 is 
successful even when something different is meant, test 7 shows that the 
method was non existent. This could have been a typo which would 
otherwise go undetected.


Regards,
Marcel




Re: [perl #131168] problems when using require ::($m)

2017-04-17 Thread mt1957 via RT
I understand that the symbols must be used in the same block as the 
require statement. There is then still a problem, namely the difference 
between linux and windows.

In the mean time I will try to get the usage of the functions to the 
block where it is required.

Marcel
> On 17-04-17 19:12, Zoffix Znet via RT wrote:
>
> thanks for the link, I will look into it.
>
> The code for which the windows implementation fails but not on linux,
> can be found here;
>
> https://github.com/MARTIMM/config-datalang-refine/blob/master/lib/Config/DataLang/Refine.pm6
>
> the requires are at line 57 and 64
> and the error is thrown at line 193 where the function is used.
>
> thanks again,
> Marcel
>
>> On Mon, 17 Apr 2017 09:53:28 -0700, mt1...@gmail.com wrote:
>>> Since I've installed perl6 version 2017.03-234-g0ebdaa4 built on MoarVM
>>> version 2017.03-128-gc9ab59c, several modules are experiencing failures
>>> when using the following construct (golfed down)(I am sure that the
>>> module loads)
>>>
>>>
>>> my $m = 'somemodule';
>>> require ::($m);
>>> my $o = ::($m).new;
>>>
>>>
>>> However, in a simple setup it works fine. I could manage to rewrite
>>> things in such a way that errors disappear, but I do not understand it.
>>> A question is 'Are the symbols loaded lexically in such a way that it is
>>> not possible to instantiate the class in another method?'
>>>
>>> A remaining bug on windows(with latest rakudostar) shows the error;
>>>
>>> Failed to load Config::TOML;
>>> Lexical with name '&from-toml' does not exist in this frame
>>>
>>> when using something like the following
>>>
>>> my $m = 'Config::TOML';
>>> require ::($m) <&from-toml>;
>>>
>>> see also
>>> https://ci.appveyor.com/project/MARTIMM/config-datalang-refine/branch/master
>>>
>>>
>>> Other things I've seen before are; not able to find the class name
>>> symbol when I want to instatiate the class, or the .^name is shorter
>>> than the real class name should be, which accounts for the first error.
>>>
>>>
>>> Regards,
>>> Marcel
>>>
>>>
>> Can't reproduce either of the issues you describe. Do you have a piece of 
>> code we can run that repos the problem?
>>
>> Also, have you seen the lexical require Upgrade Notification? 
>> http://rakudo.org/2017/03/18/lexical-require-upgrade-info/
>>
>>   my $m = 'Test';
>>   require ::($m) <&ok>;
>>   ok 1, 1;
>>   # OUTPUT: ok 1 - 1
>>
>>   my $m = 'DBIish';
>>   require ::($m);
>>   my $o = ::($m).new;
>>   dd $o;
>>   # OUTPUT: DBIish $o = DBIish.new


Re: [perl #131168] problems when using require ::($m)

2017-04-17 Thread mt1957
I understand that the symbols must be used in the same block as the 
require statement. There is then still a problem, namely the difference 
between linux and windows.


In the mean time I will try to get the usage of the functions to the 
block where it is required.


Marcel

On 17-04-17 19:12, Zoffix Znet via RT wrote:

thanks for the link, I will look into it.

The code for which the windows implementation fails but not on linux,
can be found here;

https://github.com/MARTIMM/config-datalang-refine/blob/master/lib/Config/DataLang/Refine.pm6

the requires are at line 57 and 64
and the error is thrown at line 193 where the function is used.

thanks again,
Marcel


On Mon, 17 Apr 2017 09:53:28 -0700, mt1...@gmail.com wrote:

Since I've installed perl6 version 2017.03-234-g0ebdaa4 built on MoarVM
version 2017.03-128-gc9ab59c, several modules are experiencing failures
when using the following construct (golfed down)(I am sure that the
module loads)


my $m = 'somemodule';
require ::($m);
my $o = ::($m).new;


However, in a simple setup it works fine. I could manage to rewrite
things in such a way that errors disappear, but I do not understand it.
A question is 'Are the symbols loaded lexically in such a way that it is
not possible to instantiate the class in another method?'

A remaining bug on windows(with latest rakudostar) shows the error;

Failed to load Config::TOML;
Lexical with name '&from-toml' does not exist in this frame

when using something like the following

my $m = 'Config::TOML';
require ::($m) <&from-toml>;

see also
https://ci.appveyor.com/project/MARTIMM/config-datalang-refine/branch/master


Other things I've seen before are; not able to find the class name
symbol when I want to instatiate the class, or the .^name is shorter
than the real class name should be, which accounts for the first error.


Regards,
Marcel



Can't reproduce either of the issues you describe. Do you have a piece of code 
we can run that repos the problem?

Also, have you seen the lexical require Upgrade Notification? 
http://rakudo.org/2017/03/18/lexical-require-upgrade-info/

  my $m = 'Test';
  require ::($m) <&ok>;
  ok 1, 1;
  # OUTPUT: ok 1 - 1

  my $m = 'DBIish';
  require ::($m);
  my $o = ::($m).new;
  dd $o;
  # OUTPUT: DBIish $o = DBIish.new


Re: [perl #131168] problems when using require ::($m)

2017-04-17 Thread mt1957 via RT
On 17-04-17 19:12, Zoffix Znet via RT wrote:

thanks for the link, I will look into it.

The code for which the windows implementation fails but not on linux, 
can be found here;

https://github.com/MARTIMM/config-datalang-refine/blob/master/lib/Config/DataLang/Refine.pm6

the requires are at line 57 and 64
and the error is thrown at line 193 where the function is used.

thanks again,
Marcel

> On Mon, 17 Apr 2017 09:53:28 -0700, mt1...@gmail.com wrote:
>> Since I've installed perl6 version 2017.03-234-g0ebdaa4 built on MoarVM
>> version 2017.03-128-gc9ab59c, several modules are experiencing failures
>> when using the following construct (golfed down)(I am sure that the
>> module loads)
>>
>>
>> my $m = 'somemodule';
>> require ::($m);
>> my $o = ::($m).new;
>>
>>
>> However, in a simple setup it works fine. I could manage to rewrite
>> things in such a way that errors disappear, but I do not understand it.
>> A question is 'Are the symbols loaded lexically in such a way that it is
>> not possible to instantiate the class in another method?'
>>
>> A remaining bug on windows(with latest rakudostar) shows the error;
>>
>> Failed to load Config::TOML;
>> Lexical with name '&from-toml' does not exist in this frame
>>
>> when using something like the following
>>
>> my $m = 'Config::TOML';
>> require ::($m) <&from-toml>;
>>
>> see also
>> https://ci.appveyor.com/project/MARTIMM/config-datalang-refine/branch/master
>>
>>
>> Other things I've seen before are; not able to find the class name
>> symbol when I want to instatiate the class, or the .^name is shorter
>> than the real class name should be, which accounts for the first error.
>>
>>
>> Regards,
>> Marcel
>>
>>
> Can't reproduce either of the issues you describe. Do you have a piece of 
> code we can run that repos the problem?
>
> Also, have you seen the lexical require Upgrade Notification? 
> http://rakudo.org/2017/03/18/lexical-require-upgrade-info/
>
>  my $m = 'Test';
>  require ::($m) <&ok>;
>  ok 1, 1;
>  # OUTPUT: ok 1 - 1
>
>  my $m = 'DBIish';
>  require ::($m);
>  my $o = ::($m).new;
>  dd $o;
>  # OUTPUT: DBIish $o = DBIish.new


Re: [perl #131168] problems when using require ::($m)

2017-04-17 Thread mt1957

On 17-04-17 19:12, Zoffix Znet via RT wrote:

thanks for the link, I will look into it.

The code for which the windows implementation fails but not on linux, 
can be found here;


https://github.com/MARTIMM/config-datalang-refine/blob/master/lib/Config/DataLang/Refine.pm6

the requires are at line 57 and 64
and the error is thrown at line 193 where the function is used.

thanks again,
Marcel


On Mon, 17 Apr 2017 09:53:28 -0700, mt1...@gmail.com wrote:

Since I've installed perl6 version 2017.03-234-g0ebdaa4 built on MoarVM
version 2017.03-128-gc9ab59c, several modules are experiencing failures
when using the following construct (golfed down)(I am sure that the
module loads)


my $m = 'somemodule';
require ::($m);
my $o = ::($m).new;


However, in a simple setup it works fine. I could manage to rewrite
things in such a way that errors disappear, but I do not understand it.
A question is 'Are the symbols loaded lexically in such a way that it is
not possible to instantiate the class in another method?'

A remaining bug on windows(with latest rakudostar) shows the error;

Failed to load Config::TOML;
Lexical with name '&from-toml' does not exist in this frame

when using something like the following

my $m = 'Config::TOML';
require ::($m) <&from-toml>;

see also
https://ci.appveyor.com/project/MARTIMM/config-datalang-refine/branch/master


Other things I've seen before are; not able to find the class name
symbol when I want to instatiate the class, or the .^name is shorter
than the real class name should be, which accounts for the first error.


Regards,
Marcel



Can't reproduce either of the issues you describe. Do you have a piece of code 
we can run that repos the problem?

Also, have you seen the lexical require Upgrade Notification? 
http://rakudo.org/2017/03/18/lexical-require-upgrade-info/

 my $m = 'Test';
 require ::($m) <&ok>;
 ok 1, 1;
 # OUTPUT: ok 1 - 1

 my $m = 'DBIish';
 require ::($m);
 my $o = ::($m).new;
 dd $o;
 # OUTPUT: DBIish $o = DBIish.new


Re: pod question

2017-03-01 Thread mt1957

On 03/01/2017 03:50 PM, Will Coleda wrote:

Not true, '=for' is part of POD6. See below.

If you're getting errors, it's helpful to reduce the example to a
reasonably small bit of code that duplicates the same error; either
you'll realize the issue as you remove unrelated bits of code, or
you'll end up with an example that epitomizes the problem you're
facing.


$ cat foo.p6
=for comment
This is a comment

say "hi";

$ perl6 foo.p6
hi


Hi Will,


I've tried it out and found my mistake. I continued typing after the 
first word like so


=for head1 abc def

instead of

=for head1
abc def


Many thanks,
Marcel


pod question

2017-03-01 Thread mt1957

Hi,

Is it true that the '=for' is taken out of the pod language? I get 
errors when I use it. It should take the line and the next lines as a 
block. I've also seen that it has the same effect now when I don't use it.


Regards,

Marcel


Re: syntax highlighting - uses other than atom?

2017-01-27 Thread mt1957

On 01/25/2017 10:00 AM, Richard Hainsworth wrote:
Lots of traffic on this group about syntax highlighting, which 
indicates the work has a broad application.


I've looked at the atom-language-perl6 and the main atom site, but it 
all seems quite narrow: running highlighted scripts in a single (atom) 
environment/framework.


I write and edit scripts with an editor that has a syntax highlighter 
(Kate, and overlook the bad highlighting), and if I need to play 
around with code snippets, I use REPL. How does the atom framework 
help? eg, with REPL


It seems I am missing something here.

Is there a blog/resource with a bit more explanation I can look at?


I'm also interested because of the highlighting code I have used in 
Pod::Render and other modules. This is the highlighter code from Google 
prettifier and based on javascript.


Regards

Marcel


Re: [perl #130603] Test (module) fails while all tests return ok

2017-01-21 Thread mt1957

Update...

I've used --merge on prove! This merges the outputs into one. Removing 
this option and using note for the output will give correct results



ok 1 - test 1
1..1
ok 1 - pestering 1
not ok 5 - pestering 2
ok
All tests successful.
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.15 cusr  
0.02 csys =  0.20 CPU)

Result: PASS


Re: [perl #130603] Test (module) fails while all tests return ok

2017-01-21 Thread mt1957

test should be


is 1, 1, 'test 1';
say "ok 1 - pestering 1";
say "not ok 5 - pestering 2";


resulting in


ok 1 - test 1
ok 1 - pestering 1
not ok 5 - pestering 2
1..1
Failed -1/1 subtests

Test Summary Report
---
confuse-TAP.t (Wstat: 0 Tests: 3 Failed: 1)
  Failed test:  5
  Parse errors: Tests out of sequence.  Found (1) but expected (2)
Tests out of sequence.  Found (5) but expected (3)
Bad plan.  You planned 1 tests but ran 3.
Files=1, Tests=3,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.16 cusr  
0.01 csys =  0.19 CPU)

Result: FAIL



but problem on how to cope with mixed lines with real test output remains

regards,
Marcel


Re: [perl #130603] Test (module) fails while all tests return ok

2017-01-21 Thread mt1957

Thanks very much for the explanation,
Tried the following to get the Test/TAP crying...


use Test;
is 1, 1, 'test 1';
say "ok 1 - pestering 1";
say "nok 5 - pestering 2";
done-testing;


It then generates


ok 1 - test 1
ok 1 - pestering 1
nok 5 - pestering 2
1..1
Failed -1/1 subtests

Test Summary Report
---
confuse-TAP.t (Wstat: 0 Tests: 2 Failed: 0)
  Parse errors: Tests out of sequence.  Found (1) but expected (2)
Bad plan.  You planned 1 tests but ran 2.
Files=1, Tests=2,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.15 cusr  
0.01 csys =  0.19 CPU)

Result: FAIL



Looking back in the log I found a line with a test result at the end of 
the line. This might have been missed by TAP.


2017-01-20 13:04:40.446841 [T] 1: socket found ok 2 - Scanned 200 docs, 
bad searching



Printing to stderr does not help and I get the same problems with the 
test above using 'note' instead of 'say'. It then comes down to 
refraining from printing anything to prevent any mishap. Of course, it 
is easy to prevent the 'ok ## - something' output but not when some real 
ok output ends up at the end of some other line.


Btw. the perl version was retrieved from an installation on TRAVIS where 
rakudobrew is used.


Regards,
Marcel

On 01/20/2017 10:04 PM, Zoffix Znet via RT wrote:

On Fri, 20 Jan 2017 09:16:18 -0800, mt1...@gmail.com wrote:

Hi Will,

How can it happen that a test gets hurt in this way? If I know this I
could better search for the problem.

Regards,
Marcel

Hi,

Here's how that error happens:

The TAP protocol[^1] expects tests to be numbered and (as seen in your output) 
the test harness will complain if it spots tests missing or not in order.

So if your tests produce junk output (that is something other than stuff 
produced by Test.pm6's routines), it could confuse the harness by making it 
interpret junk output as a test.

Another harder way to accomplishing that is to run the tests in multiple 
threads, to trigger a data race in the Test.pm6's internal test counter and 
make it output wrong stuff.

Yet another way is to use a buggy test harness that fails to recognize a test 
and so thinks something's missing. We had such a bug recently, though it got 
introduced on Jan 2nd and got fixed[^2] on Jan 5th. From your version, I see 
you're running Rakudo from some time in October, so this probably isn't it...

I'd suggest you try using a release version of Rakudo or HEAD. I tried running 
that test on my box, but instead of TAP output it seems to be just producing 
time-stamped connection failures.

[1] https://testanything.org/
[2] 
https://github.com/rakudo/rakudo/commit/b120ac401a0795f5f4c5fcd6e775848b4b755508





Re: [perl #130603] Test (module) fails while all tests return ok

2017-01-20 Thread mt1957

Hi Will,

How can it happen that a test gets hurt in this way? If I know this I 
could better search for the problem.


Regards,
Marcel


On 01/20/2017 05:24 PM, Will Coleda via RT wrote:

On Fri, 20 Jan 2017 06:09:00 -0800, mt1...@gmail.com wrote:

Hi,

Since using Log::Async in MongoDB I get problems while testing. All
tests run ok but at the end the Test returns failure


...

ok 6 - Testing explain and performance using hint

2017-01-20 13:04:40.783616 [I] 1: Test
/home/travis/build/MARTIMM/mongo-perl6-driver/t/450-find.t stop

1..6

Failed 3/6 subtests

... other test programs ... Test Summary Report

---

t/450-find.t (Wstat: 0 Tests: 3 Failed: 0)

Parse errors: Tests out of sequence. Found (3) but expected (1)

Tests out of sequence. Found (5) but expected (2)

Tests out of sequence. Found (6) but expected (3)

Bad plan. You planned 6 tests but ran 3.

Files=11, Tests=42, 228 wallclock secs ( 0.14 usr 0.02 sys + 208.76 cusr
9.47 csys = 218.39 CPU)

Result: FAIL



You can see complete report on Travis-ci at
https://travis-ci.org/MARTIMM/mongo-perl6-driver.

This is Rakudo version 2016.10-239-g0cf7b36 built on MoarVM version
2016.10-43-gb4cd2a6
implementing Perl 6.c.

Marcel


This is a failure on an ecosystem module, not core rakudo.

Unless there's an example of how this is explicitly a rakudo bug, this should 
be reported on https://github.com/MARTIMM/mongo-perl6-driver/issues

Regards.


Re: [perl #130338] perl6 changes breaking code

2016-12-14 Thread mt1957

Hi,

I've rebuild rakudo from the ground up. Version I get now is 
2016.11-236-g7b09bee built on MoarVM version 2016.11-41-gd2139b5 which 
looks better now. However, problem still exist. Can do for now with the 
unit package line before all use statements.


Re: [perl #130338] perl6 changes breaking code

2016-12-14 Thread mt1957

Hi,

How did you build your Perl 6?

That version number looks suspicious. You say you're on 2016.11-238-g2f502b4, 
but the current HEAD/nom is 2016.11-226-g1d46004, 12 commits fewer than yours.

The most obvious answer is you're in possession of a time machine and are 
reporting bugs from the future. In which case, would you mind including this 
week's lottery numbers in your reply?

Let us know,
Thank you.

Hi,
Well, it is one of those undocumented features of perl 6 :-) About the 
lottery: 42 42 42 42 42 42 42 ...



What I do is pulling rakudo directly from the repo like I did this 
morning(11:05 CET);


> git pull
remote: Counting objects: 159, done.
remote: Compressing objects: 100% (21/21), done.
remote: Total 159 (delta 110), reused 102 (delta 102), pack-reused 35
Receiving objects: 100% (159/159), 47.58 KiB | 0 bytes/s, done.
Resolving deltas: 100% (113/113), completed with 32 local objects.
From git://github.com/rakudo/rakudo
   5d6a8e9..7b09bee  nom-> origin/nom
...

Then
> perl Configure.pl --gen-moar --backends=moar
> make test
> make install

After the installation
> perl6 -v
This is Rakudo version 2016.11-271-g416e83b built on MoarVM version 
2016.11-41-gd2139b5


What about this version? is it better? 40 commits further than 238. 
(maybe its a pull count instead of commit count ;-)


Thanks for all of your work everyone (I must say it somewhere someplace)
Marcel


perl6 changes breaking code

2016-12-12 Thread mt1957

Hi,

Recently after pulling the newest rakudo/moarvm (2016.11-238-g2f502b4 
built on MoarVM version 2016.11-41-gd2139b5 implementing Perl 6.c) I saw 
errors in my code which compiled ok before. This is difficult to golf 
down because it disappears when used in another context. So better 
explain my way of coding.


The error I get now is

/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/xt/Sxml/driver-authentication.t 
..

===SORRY!===
Type 'MongoDB::Server' is not declared
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):152

--> my MongoDB::Server⏏ $server .= new(
Malformed my
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):152

--> my MongoDB::⏏Server $server .= new(


The module in question has the following at the top

use v6.c;

use MongoDB::Server;
use MongoDB::Database;
use MongoDB::Collection;
use MongoDB::Uri;
use MongoDB::Wire;
use MongoDB::Authenticate::Credential;
use MongoDB;

use BSON::Document;
use Semaphore::ReadersWriters;

#---
unit package MongoDB:auth;

#---
class Client {
...
  my MongoDB::Server $server .= new(
:client(self), :$server-name, :$loop-time
  );

}


The server class is defined likewise as

use v6.c;

use MongoDB;
use MongoDB::Server::Monitor;
use MongoDB::Server::Socket;
use MongoDB::Authenticate::Credential;
use MongoDB::Authenticate::Scram;

use BSON::Document;
use Semaphore::ReadersWriters;
use Auth::SCRAM;

#---
unit package MongoDB:auth;

#---
class Server { ... }


When e.g. the line 'use MongoDB::Uri' is moved above that of 
MongoDB::Server (in the Client module) another error is returned;


Type 'MongoDB::Uri' is not declared
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):99

--> my MongoDB::Uri⏏ $uri-obj .= new(:$!uri);
Malformed my
at 
/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Client.pm6 
(MongoDB::Client):99

--> my MongoDB::⏏Uri $uri-obj .= new(:$!uri);


Now I found out that when the 'unit package' line is moved above the use 
statements, the error disappears. Can anyone shed some light over this? 
I know that use statements can be used within package, module and class 
to narrow the scope of definitions but I can't remember anything which 
could explain this behavior.


Thanks,
Marcel





Re: [perl #130114] IO::Path.resolve on windows prefixed with \

2016-11-17 Thread mt1957

On 11/16/2016 09:17 PM, Zoffix Znet via RT wrote:

On Wed, 16 Nov 2016 03:01:30 -0800, mt1...@gmail.com wrote:

Hi,

On windows the path created by method resolve on windows is prefixed
with a '\' which is wrong

e.g. in project config-datalang-refine on appveyor the statement

say 'Resolve: ', '.'.IO.resolve.Str;

displays

Resolve: \C:\projects\config-datalang-refine

It shows a backslash before the volumename


Regards,

Marcel



That's probably not the only thing broken. The comment in the method (and the docs) says 
"# : Not portable yet; assumes POSIX semantics"

I.ve seen that too in the code, i'd just thought to mention it. In the 
mean time I can get by using the method abspath().


Thanks,
Marcel


Re: [perl #130050] placement of use statement

2016-11-08 Thread mt1957

Hi Will,

It is the MongoDB distribution in the file t/Test-support.pm6. It starts 
with;


use v6.c;

use MongoDB::Client;
use MongoDB::Collection;
use MongoDB::Server::Control;

and throws an error at line 119;

119:  method get-connection ( Int :$server = 1 --> MongoDB::Client ) {
$server = 1 unless $server ~~ any $!server-range;
my Int $port-number = $!server-control.get-port-number("s$server");
MongoDB::Client.new(:uri("mongodb://localhost:$port-number"));
  }


Changing the top into;

use v6.c;

use MongoDB::Collection;
use MongoDB::Server::Control;
use MongoDB::Client;

clears the error. There are many modules involved so it is difficult to 
golf it to a simpler form. The code can be found at 
https://github.com/MARTIMM/mongo-perl6-driver. You have to look into the
'develop' branch for the files. The problem file(Test-support) is in the 
attachment together with the 3 modules and the test file using the 
Test-support.


Regards,
Marcel



Test-support.pm6
Description: application/pagemaker


Client.pm6
Description: application/pagemaker


Collection.pm6
Description: application/pagemaker


Control.pm6
Description: application/pagemaker


110-Client.t
Description: Perl program


Re: small test program

2016-11-07 Thread mt1957

On 11/07/2016 04:05 AM, Mike South wrote:


On Sat, Nov 5, 2016 at 1:10 PM, mt1957 <mailto:mt1...@gmail.com>> wrote:


Hi,

I've made a small test program to run a particular test file in an
infinite loop until it fails. I was investigating some race
problem in BSON and the test run was successful most of the time.
I got some raw fingers to repeat the commands so this is the
result, simple and maybe useful for others. It uses the perl5
prove program which must be in your search path.


use v6.c;

sub MAIN ( Str:D $filename where (.IO ~~ :r and .IO !~~ :d) ) {

  my Proc $p;

  my Bool $success = True;
  while $success {
$p = shell "prove --merge -v -e perl6 $filename";
$success = $p.exitcode eq 0;
  }
}


Hi Marcel,

Thanks for sharing!

For snippets of code like this that (a) other people might find useful 
and (b) I'm likely to want to find again many months later, I like to 
store them as a "gist" at github.  Makes it easy for people to share, 
and you can search for it later if you want to dig it out again.


mike

Hi Mike,

I've done it!

See https://gist.github.com/MARTIMM/ and select prove-until-fail.pl6 
<https://gist.github.com/MARTIMM/4376afd9877173443bdbd260e84a8f02>


Thanks,
marcel




Happy testing,
Marcel Timmerman






small test program

2016-11-05 Thread mt1957

Hi,

I've made a small test program to run a particular test file in an 
infinite loop until it fails. I was investigating some race problem in 
BSON and the test run was successful most of the time. I got some raw 
fingers to repeat the commands so this is the result, simple and maybe 
useful for others. It uses the perl5 prove program which must be in your 
search path.



use v6.c;

sub MAIN ( Str:D $filename where (.IO ~~ :r and .IO !~~ :d) ) {

  my Proc $p;

  my Bool $success = True;
  while $success {
$p = shell "prove --merge -v -e perl6 $filename";
$success = $p.exitcode eq 0;
  }
}


Happy testing,
Marcel Timmerman


testing on appveyor

2016-11-05 Thread mt1957

Hi everyone,

I wanted to share something here of my newest experience about testing 
on appveyor. I had pinched a configuration file for an appveyor test, 
because it was new for me and I am not experienced on windows. It worked 
for several of my modules so I was happy until I ran into a problem.


Before running tests panda is run to install all dependencies. There it 
could not find a module in the ecosystem. This was not my experience 
running tests on Travis. After a few tests I found that the knowledge of 
panda about the modules in the ecosytem was restricted to the set known 
at the time of building rakudo star which is used on the appveyer 
server. So adding a line 'panda update' before installing updates did 
the trick.


Happy testing!
Marcel Timmerman

P.s. In the attachment you can find the appveyor config I use for most 
of the distributions I am testing.


P.s. I have filed this problem in an issue at 
https://github.com/tadzik/panda/issues/332, #332 panda can't install a 
module in windows(appveyor). I've closed that issue now.




appveyor.yml
Description: application/yaml


Re: Unexpected feature

2016-10-18 Thread mt1957

On 10/17/2016 11:34 PM, Parrot Raiser wrote:

I just downloaded the 2016.10 RC (into a different directory than
2016.07, in case it broke something).

Testing the REPL, scrolling back through the commands continued back
into the history of previous sessions with the older version. (I.e,
they appear to be accessing the same history file.)

At the moment, that seems like a very useful feature. Is it supposed
to be that way?


The history I found is at ~/.perl6/rakudo-history (on linux). I think, 
despite the different directory, you're using the same history location.


Greetings,
Marcel


Re: [perl #129212] problem mixing in role with multi builds

2016-10-17 Thread mt1957

Hi,

Revisiting the problem using rakudo version 2016.10-31-g6ed3a68 built on 
MoarVM version 2016.10 implementing Perl 6.c.


The issue still exist but tried to rewrite things to get it working


role RR1 {
  submethod BUILD ( Int :$i ) { say $i // 'No i'; }
}

role RR2 {
  submethod BUILD ( Str :$t ) { say $t // 'No t'; }
}

class CC {
  multi submethod BUILD ( Int :$i! ) {
say "Integer $i";
self does RR1;
  }

  multi submethod BUILD ( Str :$t! ) {
say "String $t";
self does RR2;
  }
}

for  {
  when 'i' {
my CC $c .= new(:i(10));
  }

  when 't' {
my CC $c .= new(:t);
  }
}


This version works, but output is

String text1
No t
Integer 10
No i

This means that the BUILD submethods in the roles are called without 
arguments, while the signatures must be the same from the use in the 
class. The required '!' must be removed(no arguments delivered).


The roles, if needed, must be initialized with a later call, e.g. via 
method init(Int $i) to get the values in the role.


Removing the submethods BUILD from the roles will trigger again the 
exception;


Cannot resolve caller BUILD(CC+{RR1}: ); none of these signatures match:
(CC $: Str :$t!, *%_)
(CC $: Int :$i!, *%_)
  in block  at Does.pl6 line 23
  in block  at Does.pl6 line 20


Greetings
Marcel


Re: subset problem

2016-09-16 Thread mt1957

The files are PRECIS.pm6 and 100-precis.t in the attachment
The Map definitions is at 13 and subset on line 20 of file PRECIS.pm6. 
Use is at method exceptions at line 172 in the same file.

The error is generated on line 85 in 100-precis.t

> prove -e perl6 -v t/100-precis.t
t/100-precis.t ..
ok 1 - À (0xc0) in Lu set
ok 2 - é (0xe9) in Ll set
ok 3 - 0x0064 in Ascii7 set
ok 4 -
1..4
ok 1 - Test tables
ok 1 - exceptions check for PVALID
ok 2 - properties check for PVALID
ok 3 - exceptions check for CONTEXTO
ok 4 - properties check for CONTEXTO
1..4
ok 2 - Test exceptions
ok 1 - 0x0005dd in letter-digits set
ok 2 - 0x0005c6 not in letter-digits set
ok 3 - 0x000660 is a CONTEXTO exception
Type check failed for return value; expected Unicode::PRECIS::PropValue 
but got Str ("PVALID")
  in method exceptions at 
/home/marcel/Languages/Perl6/Projects/unicode-precis/lib/Unicode/PRECIS.pm6 
(Unicode::PRECIS) line 175

  in block  at t/100-precis.t line 85

Dubious, test returned 1 (wstat 256, 0x100)
All 2 subtests passed

Test Summary Report
---
t/100-precis.t (Wstat: 256 Tests: 2 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
Files=1, Tests=2,  1 wallclock secs ( 0.03 usr  0.00 sys +  1.08 cusr  
0.09 csys =  1.20 CPU)

Result: FAIL





PRECIS.pm6
Description: application/pagemaker


100-precis.t
Description: Perl program


Re: subset problem

2016-09-16 Thread mt1957

Hi Fernando,

I had this problem from a module I am writing and there it went wrong 
with this error. So, not only REPL has problems. Perhaps I should write 
a bug ticket.


Marcel,

P.s. Rakudo version 2016.08.1-117-g1d8f99a built on MoarVM version 
2016.08-32-ge52414d

implementing Perl 6.c.


It works fine if the three statements are on the same line and if the 
program is being read from a file, so I guess it's bug of the REPL.


On Fri, Sep 16, 2016 at 1:49 PM, mt1957 <mailto:mt1...@gmail.com>> wrote:


Hi everyone,

I am trying to create a subset but get errors when used. Surely I
do something wrong here or is it a bug?

In REPL

> my Map $p .= new(.kv.reverse);
Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
> subset pv of Str where $_ (elem) $p;
(pv)
> my pv $x = 'aa';
Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce




--
Fernando Santagata





subset problem

2016-09-16 Thread mt1957

Hi everyone,

I am trying to create a subset but get errors when used. Surely I do 
something wrong here or is it a bug?


In REPL

> my Map $p .= new(.kv.reverse);
Map.new((:aa(4),:bb(5),:d(0),:f(1),:ff(6),:g(2),:h(3)))
> subset pv of Str where $_ (elem) $p;
(pv)
> my pv $x = 'aa';
Type check failed in assignment to $x; expected pv but got Str ("aa")
  in block  at  line 3


Greetings,

Marce



Re: [perl #127340] no line number on error

2016-08-07 Thread mt1957

On 08/06/2016 05:22 AM, Zoffix Znet via RT wrote:

Hi,

Are you able to see if the issue is still there with the latest and greatest 
Rakudo?


I haven't seen this anymore in the code while testing. There have been 
so many changes in the perl6 compiler on threads since the this ticket 
is reported that it could easily be repaired as a side effect.


So, if you like you can close this ticket.

Thanks for handling,
Marcel


Re: [perl #127339] problem using Duration

2016-08-07 Thread mt1957

On 08/06/2016 05:39 AM, Zoffix Znet via RT wrote:

Then the question remains why the multiplication results in Num if it 
multiplies with an integer

It's merely a matter that such things require addition of three extra operators 
per operation (e.g. Duration * Duration, Duration * Num, Num * Duration). 
Custom operators were added for common operations, such as addition, but rarer 
ones were omitted. For example, you can subtract two Instants,
since we commonly do {now - INIT now} but there's no operator to subtract an 
Instant from an arbitrary number.

There's *, /, div, and mod just for basic math. If we count Duration and 
Instant only that's 24 extra operators to write, debug, maintain, and most 
importantly compile and load on program start.

Since in rarer use cases for which there isn't currently an operator the 
programmer can simply coerce the value to anything they want, it makes sense to 
not create custom operators for every imaginable case.

For those reasons, I'm rejecting this ticket.


Hi Zoffix,

I understand completely, thanks for looking into it.

Marcel



Re: [perl #128628] problem using semaphore with many threads

2016-07-28 Thread mt1957

On 07/28/2016 03:00 PM, Jonathan Worthington via RT wrote:

On Fri, Jul 22, 2016 at 10:46 AM, mt1957 via RT <
perl6-bugs-follo...@perl.org> wrote:


I'm afraid the test I've created still hangs in rakudo version
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d
implementing Perl 6.c.

That's still a too old MoarVM version. You'd need to explicitly build the

master branch of MoarVM, not version 2016.07-3-gc01472d. Also I put another
semaphore fix in yesterday, and had it run to completion 1000 times without
problem. Will bump the MoarVM version Rakudo requires shortly, anyway,
which will save the manual build.

/jnthn


Hi Jonathan,

Thanks very much for your work, I'll wait and see. I pull rakudo 
versions directly from the github and some day it will be working :-).


Thanks again for all of your work,

Marcel



Re: [perl #128628] problem using semaphore with many threads

2016-07-24 Thread mt1957

On 07/21/2016 02:52 PM, jn...@jnthn.net via RT wrote:

On Fri Jul 15 12:32:30 2016, mt1...@gmail.com wrote:

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).


my Semaphore $s .= new(1);

my @p;
my $r;
for ^4000 {
my $i = $_;

@p.push: Promise.start( {

$s.acquire;
print "+";

# critical code area
$r += $i;

$s.release;
print "-";
  }
);
}


This is largely addressed by:

https://github.com/MoarVM/MoarVM/commit/236058a6c8bd91eacf100047831ac77e4ad486b7

However, there is an occasional GC orchestration hang that I'm still looking 
into.

Hi Jonathan,

I'm afraid the test I've created still hangs in rakudo version 
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d

implementing Perl 6.c.

This time only 80 threads started and using '$r += [+] $i, 3, 4, 5, 6, 
7, 8, 9, 10;' in the critical section.


Btw, a problem in [+] might exist because changing that into '$r += $i + 
3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;' the code is running flawlessly even 
with 4000 threads.


Greetings,

Marcel

p.s. email sent to perl6-compi...@perl.org before but now sent also to 
perl6-bugs-followup


Re: [perl #128628] problem using semaphore with many threads

2016-07-22 Thread mt1957

On 07/21/2016 02:52 PM, jn...@jnthn.net via RT wrote:

On Fri Jul 15 12:32:30 2016, mt1...@gmail.com wrote:

With Rakudo version 2016.06-234-g0189851 built on MoarVM version
2016.06-9-g8fc21d5
implementing Perl 6.c on a Asus laptop running Fedora 23 I see the
following happen. Running the code below is doing well but when the code
in the critical section gets complex (e.g. '$r += [+] $i, 3, 4, 5, 6, 7,
8, 9, 10;'), the program does not finish. The output of the '+' and '-'
stops but the cpu (2 or 3 of 8) will go to 100% usage (user time, not
system time).


my Semaphore $s .= new(1);

my @p;
my $r;
for ^4000 {
my $i = $_;

@p.push: Promise.start( {

$s.acquire;
print "+";

# critical code area
$r += $i;

$s.release;
print "-";
  }
);
}


This is largely addressed by:

https://github.com/MoarVM/MoarVM/commit/236058a6c8bd91eacf100047831ac77e4ad486b7

However, there is an occasional GC orchestration hang that I'm still looking 
into.

Hi Jonathan,

I'm afraid the test I've created still hangs in rakudo version 
2016.07.1-37-g60f256d built on MoarVM version 2016.07-3-gc01472d

implementing Perl 6.c.

This time only 80 threads started and using '$r += [+] $i, 3, 4, 5, 6, 
7, 8, 9, 10;' in the critical section.


Btw, a problem in [+] might exist because changing that into '$r += $i + 
3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;' the code is running flawlessly even 
with 4000 threads.


Greetings,

Marcel



Re: [perl #128655] Mixup in candidates through optimizer

2016-07-18 Thread mt1957

Hi Elizabeth,

Need to mention that there was a ticket #128624 created 'Buf 
initialization error'.


Regards,
Marcel Timmerman


resource limits

2016-07-08 Thread mt1957

Hi,

I am running tests with a lot of threads. I've seen that when I push it 
to about 200 threads, it can get into trouble when the task of the 
thread is large enough. Now, looking at some system monitor(atop on 
linux), I can see that the user time of 3 or 4 processors(of 8) soared 
up to 100% but not finishing the tasks. In one of those sessions I even 
got got an error (reported bug #128172):


*** Error in `/home/marcel/Software/perl6/rakudo/install/bin/moar': 
double free or corruption (fasttop): 0x05da0090 ***


or the test is finished in a abrupt way saying that there are 'no 
subtests run'. Or it can give other errors like;


Cannot invoke this object (REPR: Null; VMNull)
  in block  at t/100-rw.t line 118
  in block  at t/100-rw.t line 118

It gives an indication that the program gets corrupted at some point 
which is of course not good but where it happens is not tracable for me. 
Not easy to golf this down e.g. less treads (50 or even a 100 with less 
work) always finish properly.


The question I have now is how to check in a program for resource info 
so that the program can behave like a nice computer citizen.


Greetings,
Marcel

I've included the sources for anyone interested. The tests are commented 
out except for the 'readers and writers' test. Here the number of 
threads is 100 with 40 writers and 60 readers. This is to test the 
semaphore readers writers pattern. The module is not yet completed. It 
will be published in the ecosystem when ready.


This is Rakudo version 2016.06-178-gf7c6e60 built on MoarVM version 
2016.06-9-g8fc21d5

implementing Perl 6.c.



ReadersWriters.pm6
Description: application/pagemaker


100-rw.t
Description: Perl program


Re: [perl #128289] localhost in IO::Socket::INET

2016-05-29 Thread mt1957

On 05/29/2016 07:47 PM, Brandon Allbery via RT wrote:

getent hosts


> getent hosts on faulty system
127.0.0.1   localhost localhost.localdomain localhost4 
localhost4.localdomain4
127.0.0.1   localhost localhost.localdomain localhost6 
localhost6.localdomain6



On ok system. It differs only in the second line

127.0.0.1   localhost localhost.localdomain localhost4 
localhost4.localdomain4

127.0.0.1   localhost6 localhost6.localdomain6

I've removed the localhost localhost.localdomain part from the second 
line in /etc/hosts and after that the test went ok. So this was really a 
quick fix.



Thanks,

Marcel



Re: [perl #128156] dependency errors

2016-05-24 Thread mt1957

Hi,

Another symptom from the same bug. After modifying a sub module I get an 
error like the following;



Type 'Semi-xml::Sxml' is not declared
at /home/marcel/Languages/Perl6/Projects/Semi-xml/t/108-xml.t:43
--> my Semi-xml::Sxml⏏ $x .= new;
Malformed my
at /home/marcel/Languages/Perl6/Projects/Semi-xml/t/108-xml.t:43
--> my Semi-xml::⏏Sxml $x .= new;


Then, after modifying the top module (just a simple say), everything 
runs ok again.


This is Rakudo version 2016.04-209-gdb10a01 built on MoarVM version 
2016.04-134-g9879233


Greetings,
Marcel


Re: How to capture an div 0 exception

2016-05-18 Thread mt1957

Hi Richard,

This has something to do with lazy evaluation. It triggers the 
calculation when it wants to show the value in $r. So commenting out the 
first 'say' will error on the second with the shown response. The CATCH 
is not at the same scope than the second 'say' statement so there you 
get a different action.


Something interesting might be when changing the expression into '$r = 5 
/ (3 - $s).Num;' You get a different response and you will not need the 
CATCH at all. Just test on Inf if you need to change it.


An example;

use v6;

my $r;
for 0..4 -> $s {
   $r = (5 / (3 - $s));
   $r = 42 if $r.Num ~~ Inf;

   say "At line $?LINE r is $r";
}

Response

At line 10 r is 1.67
At line 10 r is 2.5
At line 10 r is 5
At line 10 r is 42
At line 10 r is -5

Greetings,
Marcel


Marcel and Moritz,

Thank you for the fast response.

I have been experimenting with the code you sent, but still do not
understand something. To illustrate, here is another snippet:
use v6;
my $r;
for 0..4 -> $s {
   {
 $r = 5 / (3 - $s);
 say "At line $?LINE r is $r";
 CATCH {
   when X::Numeric::DivideByZero { $r = 65 }
   default { $r = 55 }
 }
}
say "At line $?LINE r is $r";
}
### result is
At line 6 r is 1.67
At line 12 r is 1.67
At line 6 r is 2.5
At line 12 r is 2.5
At line 6 r is 5
At line 12 r is 5
At line 12 r is 65
At line 6 r is -5
At line 12 r is -5

 However,
use v6;
my $r;
for 0..4 -> $s {
   {
 $r = 5 / (3 - $s);
 say "At line $?LINE r is $r";
 CATCH {
   when X::Numeric::DivideByZero { $r = 65 }
   default { $r = 55 }
 }
}
say "At line $?LINE r is $r";
}
 result is
At line 12 r is 1.67
At line 12 r is 2.5
At line 12 r is 5
Attempt to divide 5 by zero using div
  in block  at test.pl line 12

Actually thrown at:
  in block  at test.pl line 12

It seems that the commented out 'say' statement is required to get the
CATCH statement to "trigger".
a) Why is the exception not caught the assignment statement?
b) What other statement (NO OP) can I use in place of the commented
out 'say' statement?

Clearly, I do not have a good understanding of the Exception
mechanism. Your help in understanding is appreciated.

Richard





Re: How to capture an div 0 exception

2016-05-18 Thread mt1957

On 18-05-16 13:07, Richard Hainsworth wrote:

use v6;
my $d = 1;
my $e = 2;
my $f = 0;
#my $r;
my $r = 5;

CATCH {
# when X::AdHoc {
when Exception {
.Str.say;
# $r = 5;
 .resume
} }

$r = try {
( $d + $e ) / $f;
};

# my $r = try EVAL ' ( 1 + 2 ) /0 ';

say "r is $r";


Hi Richard,

There are a few things to mention;

Write CATCH in a block. In that block you must test the things which 
might go wrong. Like so;


try {
   ...
   CATCH {
 when  {
 
 }

 default {
 ...
 }
   }
}

Below there is some other code about your example;

my $r;
{
   try {
 my $d = 1;
 my $e = 2;
 my $f = 0;

 $r = ( $d + $e ) / $f;
 say "r is $r";

 CATCH {

   .WHAT.say;
   when X::Numeric::DivideByZero {
 $r = 65;
 .resume;
   }

   default {
 $r = 55;
 .resume;
   }
 }
   }

   say "r is $r";
}

This will not produce your desired answer but the following;

(DivideByZero)
(NoMatch)
(AdHoc)
This exception is not resumable
   in block  at t0-email.pl6 line 26
   in block  at t0-email.pl6 line 14
   in block  at t0-email.pl6 line 7

You see that '.WHAT.say' shows several types of exceptions. This is 
caused by the resumes and in the end it gets one which is not resumable.


When you remove both resume statements you will get the output 'r is 65' 
which is what you want. Also here you can see that the test against 
X::Numeric::DivideByZero is taken.


Hope this helps,
Marcel



Re: Some proposed Perl 6 pod projects for comment

2016-05-15 Thread mt1957

Hi Tom,


Pod::To::PDF
==

Nice to have.  It could use something like p6pod2latex as an
intermediate filter and then use popular LaTeX tools to generate the PDF.
At the moment I am writing pod6 in separate files with the following at 
the top of such a file. It needs wkhtmltopdf for this to work. In the 
example below you can see css style things to format
specific items of the generated html from Pod::To::HTML. It might give 
you some ideas.


Greetings,
Marcel


#!/usr/bin/env perl6
#
use v6.c;

# Running the pod file will create a pdf using wkhtmltopdf
#
my Str $pod = "$*PROGRAM";
my Str $pdf = $pod;
$pdf ~~ s/\. <-[.]>+ $/.pdf/;
shell( "perl6 --doc=HTML '$pod' | wkhtmltopdf - '$pdf'");

=begin pod

=begin Xhtml

   pre {
 border-width:   2px;
 border-style:   solid;
 border-color:   #060;
 padding:10px 0 3px 10px;
 color:  #060;
 background-color:   #eaefea;
 font-family:FreeMono;
   }
   td {
 vertical-align: top;
   }

=end Xhtml

=TITLE class MongoDB::Server

...

=end pod




Re: [perl #128036] Bug filling hash using $_

2016-04-30 Thread mt1957

More simplified code producing the same error;

$_ = 'some message';
my Hash $h = {
  f1 => $_,
}

greetings
Marcel


# New Ticket Created by  mt1957
# Please include the string:  [perl #128036]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=128036 >


Hi,

Had some strange problem to solve... Could golf it down to the following;

*class A {**
**  method message ( ) { 'some message'; }**
**}**

**my A $a .= new;**
**
**$_ = $a;**
**my Hash $h = {**
**  key => $_.message(),**
**}**
*
Error generated is;

Type check failed in assignment to $h; expected Hash but got Block (->
;; $_? is raw { #`...)
in block  at hash.pl6 line ...

All is fine when *$_.message(),***is substituted with *$a.message(),**
*
A workaround for the moment is to assign the result of the method to a
Str variable which then can be used in the Hash.

Greetings,
Marcel





question about Supply.act()

2016-04-28 Thread mt1957

Hi,

The documentation about the method act explains that 'the given code is 
guaranteed to be only executed by one thread at a time'.


Can I assume from this that any other thread including the main thread 
isn't running? I want to know if I need to guard the data with 
semaphores I am changing in that thread.


Regards,
Marcel


Re: Blobs and IEEE floating point

2016-04-20 Thread mt1957


On 19-04-16 10:21, Elizabeth Mattijsen wrote:

FWIW, I’ll take PR’s for the PackUnpack distribution to make ‘f’ and ‘d’ work  
:-)


Hi Elizabeth,

For the PackUnpack distro this might come in handy... or might go in the 
examples corner?


Done some experiments and looks well. Please check the attachment for 
encoding/decoding of doubles. decode-double has also an index in the 
buffer to pull out a specific spot in the buffer where the encoded 
double should be. The code is made from snippets from Timo Paulsen and

David Warren.

You might want to know how much faster it has become. Well it's not that 
much of an improvement, only encoding a double is about 4 times faster.  
The decoding only 1.13 times.


emulated encoded
3000 runs total time = 7.211524 s, 0.002404 s per run, 416.000809 runs per s

native encoded
3000 runs total time = 1.720918 s, 0.000574 s per run, 1743.256109 runs 
per s


emulated decode
3000 runs total time = 1.038615 s, 0.000346 s per run, 2888.461538 runs 
per s


native decode
3000 runs total time = 0.918133 s, 0.000306 s per run, 3267.498734 runs 
per s



Before I pat myself on the back for the 'fast' emulated encode/decode 
already in place in the BSON package the above results might mean that 
the native routines can be done better.


Regards,
Marcel


#!/usr/bin/env perl6

use v6.c;
use NativeCall;

say 'little endian: ', little-endian;

for ( 0.3e3, 0.2, -20.45e-20, Inf, NaN) -> $r {

  say "Encode $r";

  my Buf $b = encode-double(Num.new($r));
  say $b.list.fmt('%02x');

  say "Decoded num = ", decode-double( $b, 0);
}

#-
# encode Num in buf little endian
#
sub encode-double ( Num:D $r --> Buf ) {

  my CArray[num64] $da .= new($r);
  my $list = nativecast( CArray[uint8], $da)[^8];
  if little-endian() {
Buf[uint8].new($list);
  }

  else {
Buf[uint8].new($list.reverse);
  }
}

#-
# decode to Num from buf little endian
#
sub decode-double ( Buf:D $b, Int:D $index --> Num ) {

  my Buf[uint8] $ble;
  my $list = $b.list;
  if little-endian() {
$ble .= new($b.subbuf( $index, 8));
  }

  else {
$ble .= new($b.subbuf( $index, 8).reverse);
  }

  nativecast( CArray[num64], $ble)[0];
}

#-
sub little-endian ( --> Bool ) {

  my $i = CArray[uint32].new: 1;
  my $j = nativecast( CArray[uint8], $i);

  $j[0] == 0x01;
}


Re: Blobs and IEEE floating point

2016-04-19 Thread mt1957

Hi Timo,

Thanks for the code snippets, I can use that too. There is already some 
code to test endianness

see mail from David Warring at my question about Union. Date April 4 2016.

Greetings,
Marcel




On 19/04/16 16:25, Elizabeth Mattijsen wrote:
> I’ve been looking at nativecast, but haven’t been able to find an > example 
that I could apply to this?
>
> Liz

Right! I should have given a working example, or at least mention that 
CArray would probably be necessary to make this work.


Here's one to go from a num to an int:

perl6 -e 'use NativeCall; my CArray[num64] $foo .= new(1234e9); say 
nativecast(CArray[int64], $foo)[0].fmt("0x%x")'

0x4271f5021b40

And if you want the bytes directly, as if in a buffer, you'd probably 
do something like


perl6 -e 'use NativeCall; my CArray[num64] $foo .= new(1234e9); say 
Buf[uint8].new(nativecast(CArray[uint8], $foo)[^8])'

Buf[uint8]:0x<00 00 40 1b 02 f5 71 42>

Hope that helps!
  - Timo




Re: importing code

2016-03-10 Thread mt1957

Op 10-03-16 om 20:14 schreef yary:

There's "require" to load a module at runtime

http://docs.perl6.org/syntax/require

The $*REPO object controls how to search for modules,
http://docs.perl6.org/language/5to6-perlvar mentions it. I don't know
much more than that,

Thanks for your answer,

I've played a little with require in REPL but there is a problem

I would like to do the following...

> my $m = 'some-module';
> require $m;
Could not find 'some-documnt' in:
/home/marcel
/home/marcel/lib
/home/marcel/.perl6/2016.02-95-g2f78f05
/home/marcel/Software/perl6/rakudo/install/share/perl6/site
/home/marcel/Software/perl6/rakudo/install/share/perl6/vendor
/home/marcel/Software/perl6/rakudo/install/share/perl6
CompUnit::Repository::AbsolutePath<74011248>
CompUnit::Repository::NQP<72611240>
CompUnit::Repository::Perl5<72611280>

while directly used it works

> require some-module;
>

Do you think it's a bug. If so I'll write this also to rakudo-bug.

Marcel



Re: [perl #127340] no line number on error

2016-01-23 Thread mt1957

On 01/23/2016 06:04 PM, jn...@jnthn.net via RT wrote:

On Sat Jan 23 07:08:17 2016, mt1...@gmail.com wrote:

On 01/21/2016 06:44 PM, mt1957 wrote:

On 01/21/2016 06:35 PM, mt1957 (via RT) wrote:

# New Ticket Created by  mt1957
# Please include the string:  [perl #127340]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=127340 >


L.s.

Got this error;

Internal error: zeroed target thread ID in work pass

I really don't know where this happens, except it has something to with
threads using Promise

Greetings
Marcel Timmerman

Following is done. I guessed that the line just entered was perhaps a
problem so commented it out. Run the program and the error was gone.
Then, removed the '#' and run again. still gone! weird!

Race conditions perhaps?

I've found the line of the error message in nqp/MoarVM/src/gc/collect.c
at line 439.

Found in;
This is Rakudo version 2015.12-201-g2a8ca94 built on MoarVM version
2015.12-29-g8079ca5
implementing Perl 6.c.

After upgrade of rakudo the message was gone again... (the code in
collect.c was not changed)
This is Rakudo version 2015.12-221-gb340ad5 built on MoarVM version
2015.12-29-g8079ca5
implementing Perl 6.c.

This is a tricky thing for I do not know how to test it and what
conditions it needs to reproduce it.


The error is from the VM, and indicates that while performing garbage 
collection some kind of memory corruption was encountered. It's highly unlikely 
to indicate a bug in your program, unless you're (mis)using NativeCall. 
Furthermore, the bug is almost never in the garbage collector itself; rather, 
something else somewhere in the VM broke an invariant the GC depends on. So, 
the place things went wrong and the place we realize it can be enormously 
different (that is, the corruption could have occurred some millions of CPU 
instructions ago before we find it). And any change to memory layout can easily 
hide it.

Typically, such things are horrible to debug, though typically we start off by 
building a MoarVM with a tiny nursery size to make GC happen very often, and so 
hopefully to flag up the problem very quickly.

How big is the program that triggers the problem? Is it something you're able 
to share (perhaps privately)?
There are quite a few classes/modules in two projects, It is the MongoDB 
project which can be found at 
https://github.com/MARTIMM/mongo-perl6-driver and is using BSON to be 
found at https://github.com/MARTIMM/BSON


To check the current code use the development branch for the mongo code. 
For the bson code, the master branch is ok.


First it is easy to install the BSON code with panda, then get the mongo 
driver code from github


To run the tests a mongod server must be installed and the test 
t/000-mk-sandbox.t expects it at
/usr/bin/mongod. However it might be easier to set the environment 
variable TRAVIS to 1 and  run
*'sh Travis-ci/install-mongodb.sh 3.0.5*'. It will get the version of 
mongod server I am testing against in the Travis-ci directory. Then the 
first test creates a Sandbox and starts the server at localhost:65000 if 
that one is available, then makes a note in the Sandbox directory and is 
used in all of the other tests. At first the startup will take some time 
because the server needs some workfiles to initialize.


The threading code using Promise can be found in the modules 
lib/BSON/Document.pm6 in the BSON project and also in the 
lib/MongoDB/Client.pm6 and lib/MongoDB/Server.pm6 in the mongo driver 
project.


The code runs ok with the perl version: ' Rakudo version 
2015.12-221-gb340ad5 built on MoarVM version 2015.12-29-g8079ca5 
implementing Perl 6.c.'


The previous version which gave a problem in test t//301-Collection.t; 
'Rakudo version 2015.12-201-g2a8ca94 built on MoarVM version 
2015.12-29-g8079ca5 implementing Perl 6.c.'.


Having said this, a last test showed the error again using *'prove -e 
perl6 t*' when at t/200-Database.t. It disappears when using the -v option.


Hopefully this is enough information to work with,

Regards
Marcel Timmerman



Re: [perl #127340] no line number on error

2016-01-23 Thread mt1957

On 01/21/2016 06:44 PM, mt1957 wrote:

On 01/21/2016 06:35 PM, mt1957 (via RT) wrote:

# New Ticket Created by  mt1957
# Please include the string:  [perl #127340]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=127340 >


L.s.

Got this error;

Internal error: zeroed target thread ID in work pass

I really don't know where this happens, except it has something to with
threads using Promise

Greetings
Marcel Timmerman
Following is done. I guessed that the line just entered was perhaps a 
problem so commented it out. Run the program and the error was gone. 
Then, removed the '#' and run again. still gone! weird!


Race conditions perhaps?
I've found the line of the error message in nqp/MoarVM/src/gc/collect.c 
at line 439.


Found in;
This is Rakudo version 2015.12-201-g2a8ca94 built on MoarVM version 
2015.12-29-g8079ca5

implementing Perl 6.c.

After upgrade of rakudo the message was gone again... (the code in 
collect.c was not changed)
This is Rakudo version 2015.12-221-gb340ad5 built on MoarVM version 
2015.12-29-g8079ca5

implementing Perl 6.c.

This is a tricky thing for I do not know how to test it and what 
conditions it needs to reproduce it.






Re: [perl #127339] problem using Duration

2016-01-22 Thread mt1957

On 01/22/2016 01:52 PM, Sam S. via RT wrote:

This is the root of the problem:

   ➜ say ($d + 2).WHAT;
   (Duration)
   
   ➜ say ($d * 2).WHAT'

   (Num)

The behavior of += and *= is just a consequence of that.
Then the question remains why the multiplication results in Num if it 
multiplies with an integer. Besides, addition of a Num still becomes a 
Duration. See following REPL;


> my Duration $d .= new(10);
10
> $d += 1.1
11.1
> $d += 1.1
12.2
> $d.WHAT.say
(Duration)




Re: [perl #127340] no line number on error

2016-01-21 Thread mt1957

On 01/21/2016 06:35 PM, mt1957 (via RT) wrote:

# New Ticket Created by  mt1957
# Please include the string:  [perl #127340]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=127340 >


L.s.

Got this error;

Internal error: zeroed target thread ID in work pass

I really don't know where this happens, except it has something to with
threads using Promise

Greetings
Marcel Timmerman
Following is done. I guessed that the line just enetered was perhaps a 
problem so commented it out.
Run the program and the error was gone. Then, removed the '#' and run 
again. still gone! weird!


Race conditions perhaps?




Re: thread problem

2016-01-13 Thread mt1957

On 01/13/2016 04:39 PM, Will Coleda wrote:

Hi Will,

First I must say that the code is still in development so it might look 
a bit messy. Now the test file uses the Client to get a MongoDB server 
using host and port info. This info can default to localhost and port 
27017. The tests are using a server setup to run at localhost and port 
65000. The Client on its turn will try to manage more servers which are 
setup using threads(Promises). At the moment only one but it is setup to 
provide for multiple connections to servers in the same replica set,


When a connection is made a database object is made which uses 
run-command to run a command to drop a database. This will go through a 
Collection ending up in Wire(using query()) to send the encoded data to 
the mongo server. This request expects an answer which is read a few 
lines further on. On this place (line 40) I get the error.


You will notice that as a workaround I've closed the port before 
returning the object(At line 38 in Connection). The port will be 
reopened when the send/receive is called. When I don't close it I will 
get the above mentioned error.


Thanks for looking into it
Marcel

B.t.w. This is Rakudo version 2015.12-201-g2a8ca94 built on MoarVM 
version 2015.12-29-g8079ca5

implementing Perl 6.c.


Can you post the code that causes the issue?

On Wed, Jan 13, 2016 at 4:00 AM, mt1957  wrote:

L.s.

I got the following error

'Tried to read() on a socket from outside its originating thread'

This socket is created while in another thread using Promise and the object
is retrieved using
$promise.result. The weird thing is also that just a few lines before that
the same socket is used for writing! This write completed successfully and
data is seen traveling using wireshark.

Is there something still unfinished in a thread or is there some status not
reset?

Marcel Timmerman







use v6;

# use lib '/home/marcel/Languages/Perl6/Projects/BSON/lib';

use MongoDB::Connection;
use BSON::Document;

package MongoDB {

  #-
  #
  class Client {

#TODO refine this method of using server name/port, connection pooling etc

my Array $server-connections;   # Array of connections
my Array $server-discovery; # Array of promises

#---
#
multi submethod BUILD (
  Str :$host,
  Int :$port where (!$_.defined or 0 <= $_ <= 65535),
  Str :$url
) {

  $server-connections = [] unless $server-connections.defined;
  $server-discovery = [] unless $server-discovery.defined;

  my Pair @server-specs = ();
  my Str $server-name;
  my Int $server-port;

say "H & P: {$host//'nh'}, {$port//'np'}, {$url // 'nu'}";

  if ?$url {
#TODO process url
#$server-name = 'localhost';
#$server-port = 27017;
  }

  else {
# Test for the server name. When no cases match a previously stored
# server name is taken
#
if !?$host and !?$server-name and !?$url {
  $server-name = 'localhost';
}

elsif ?$host {
  $server-name = $host;
}

# Test for the server port. When no cases match a previously stored
# server port is taken
#
if !$port.defined and !$server-port.defined {
  $server-port = 27017;
}

elsif $port.defined {
  $server-port = $port;
}

@server-specs.push: ($server-name => $server-port);
  }

  # Background process to discover hosts only if there are no servers
  # discovered yet or that new non default cases are presnted.
  #
  if !$server-connections.elems
 or $server-name ne 'localhost'
 or $server-port != 27017 {

for @server-specs -> Pair $spec {
  $server-discovery.push: Promise.start( {
  MongoDB::Connection.new(
:client(self),
:host($spec.key),
:port($spec.value)
  );
}
  );
say "KV: {$spec.kv}, {@server-specs.elems}, {$server-discovery.elems}";
}
  }
}

#---
# Server discovery
#
method !discover-servers ( ) {

}

#---
#
#method select-server ( Bool :$need-master = True --> MongoDB::Connection ) 
{
method select-server ( --> MongoDB::Connection ) {

  my MongoDB::Connection $server;
  while !$server.defined {
my Bool $isMaster = False;

loop ( my $pi = 0; $pi < $server-discovery.elems; $pi++ ) {
  my $promise = $server-discovery[$pi];
say "P: $pi, ", $promise.WHAT;

thread problem

2016-01-13 Thread mt1957

L.s.

I got the following error

'Tried to read() on a socket from outside its originating thread'

This socket is created while in another thread using Promise and the 
object is retrieved using
$promise.result. The weird thing is also that just a few lines before 
that the same socket is used for writing! This write completed 
successfully and data is seen traveling using wireshark.


Is there something still unfinished in a thread or is there some status 
not reset?


Marcel Timmerman



Re: [perl #127247] [BUG] Circular dependancy lock rakudo in an infinite loop

2016-01-12 Thread mt1957

On 01/12/2016 02:26 PM, Sylvain Colinet (via RT) wrote:

# New Ticket Created by  Sylvain Colinet
# Please include the string:  [perl #127247]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=127247 >


Using https://gist.github.com/Skarsnik/df17adee07c18fa52c00 as a test

Perl6 just go on forever. Tested with a recent Rakudo

skarsnik@testperl6:~/devel/tmp$ ../rakudo/install/bin/perl6 --version
This is Rakudo version 2015.12-198-g997d7d1 built on MoarVM version 
2015.12-29-g8079ca5
implementing Perl 6.c.

See also bug 126688 bug detecting circular dependencies


panda and documentation

2016-01-11 Thread mt1957

L.s.

I have written my documentation in separate pod files. How do I mention 
this in the META.info file and

where will panda install the documentation

Greetings
Marcel


Re: order of input using Capture

2016-01-11 Thread mt1957

On 01/11/2016 06:58 PM, mt1957 wrote:

Thanks for the information I didn't know about this detail.

What about the order of input, when a call is made and a Capture 
created the order is preserved
otherwise the arguments would be bound to the wrong values isn't it? 
But the example shows otherwise.
Aha, I understand now, named argument are repositioned to the back while 
the rest is still the same order but at the front





Re: order of input using Capture

2016-01-11 Thread mt1957

Thanks for the information I didn't know about this detail.

What about the order of input, when a call is made and a Capture created 
the order is preserved
otherwise the arguments would be bound to the wrong values isn't it? But 
the example shows otherwise.


order of input using Capture

2016-01-11 Thread mt1957

L.s.

I've seen that the order of input to a Capture is not kept. Is this a bug?

REPL interaction;

> my Capture $c = \(a=>1,10,{w=>2},[2,3],(e=>2),(b=>3,),Buf.new(^3))
\(10, {:w(2)}, [2, 3], :e(2), (:b(3),), Buf.new(0, 1, 2), :a(1))

> for $c.list -> $item { $item.WHAT.say;}
(Int)
(Hash)
(Array)
(Pair)
(List)
(Buf)

Last item is missing, a pair :a(1). $c.elems reports 6 elements. I'm not 
sure but there was a bug report about it I believe.


Greetings
Marcel Timmerman


Re: Use of ':' in identifiers

2016-01-06 Thread mt1957

Hi Tobias,
$foo:bar and Foo:bar are variable/package names with an colonpair 
appended. The entire thing is then called a longname, at least 
internally.


Test:ver(v1) makes it clearer what it does. You $abc:def example boils 
down to $abd:def(True) btw.
Thanks for your answer. I now found something in the synopsis s99 which 
shows me the usage of it. Now I also understand that it is about multi 
methods and stuff. Excerpt shown below


longname

Because Perl 6 has the capability of "multiple dispatch" 
, several methods or 
subroutines may have the same name but different parameters (different 
in number or in type). Perl decides which routine to call by looking at 
the *longname* which consists of the name of the routine and the type 
signature of its invocant arguments. See also "shortname" 
, "multi-method" 
, and "multi-sub" 
.





Use of ':' in identifiers

2016-01-06 Thread mt1957

L.s.

I'am a bit confused about the use of ':' in an identifier. I've read a 
bit about the ':' twigil but that seems to be used at the front of the 
id giving it a special use. Under 'identifiers' on the syntax page I 
couldn't find any about it. So I am referring to things like $abc:def 
and the like. Is there information in the synopsis documents?


Thanks in advance
Marcel Timmerman


Re: [perl #127107] "duplicate definition of symbol grammar" using Grammar::Tracer in .pm6 file

2015-12-31 Thread mt1957

On 12/31/2015 01:47 PM, Faye (via RT) wrote:

# New Ticket Created by  Faye
# Please include the string:  [perl #127107]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=127107 >


$ cat Foo.pm6
use Grammar::Tracer;
$ perl6 -I. -e 'use Foo'
===SORRY!===
P6M Merging GLOBAL symbols failed: duplicate definition of symbol grammar

It appears that, for whatever reason, using Grammar::Tracer from within a 
module file causes that strange low-level error. Note that attempting 'use 
Grammar::Tracer' in a non-module file or directly in one-liners doesn't seem to 
be an issue:

$ perl6 Foo.pm6
$ perl6 -e 'use Grammar::Tracer'
$
See also messages with subject 'lack of info in error message' from 
mt1...@gmail.com


summarized here... (p.s. the test file is from my own project and the 
symbol is defined by using constant)



I get the following error;

perl6 t/070-run-command.t
===SORRY!===
P6M Merging GLOBAL symbols failed: duplicate definition of symbol C-MD5-SIZE

Searching for the symbol gave me exactly one location where it was 
defined. So the error should be more explicit in where it was first 
found and where the second throws the error. In the mean time I found 
that ordering of use statements make a difference after which the error 
disappears.







Re: [perl #126688] bug detecting circular dependencies

2015-12-31 Thread mt1957

On 12/31/2015 06:58 AM, Dave Rolsky via RT wrote:

I can confirm that this is still happening as of today's rakudo. It seems like 
an important bug to fix, but maybe more importantly, how are we supposed to 
handle circular deps? Consider a pair of classes, Tree and Node, which both 
need to refer to each other.

Tree.pm6


unit class Tree;

use Node;

has Node $top;



Node.pm6


unit class Node;

use Tree;

has Tree $tree;


Given that I have to use a module in order to refer to its type, this seems 
like a problem that will occur _way_ more often in Perl 6 than in Perl 5.


Often you  can cope by not typing them in both modules . Then e.g. the 
node create method in the Tree module creates the Node object which 
receives the Tree object via the BUILD method. The Node module then does 
not have to import the tree module because all information is included 
in the Tree object just received. So the 'use Tree;' in Node.pm is not 
needed.






Re: lack of info in error message

2015-12-30 Thread mt1957

On 12/30/2015 10:43 AM, Elizabeth Mattijsen wrote:

On 30 Dec 2015, at 09:48, mt1957  wrote:


I get the following error;

perl6 t/070-run-command.t
===SORRY!===
P6M Merging GLOBAL symbols failed: duplicate definition of symbol C-MD5-SIZE

Searching for the symbol gave me exactly one location where it was defined. So 
the error should be more explicit in where it was first found and where the 
second throws the error.

Which t/070-run-command.t are you talking about?  This does not seem to be part 
of the rakudo compiler distribution?


Sorry, no, this is a test program from my own project mongodb driver.
In the mean time I found that ordering of use statements make a 
difference which I think is perhaps a problem. Also use statements can 
be removed from the code if they are also been used in the imported modules.





lack of info in error message

2015-12-30 Thread mt1957


I get the following error;

perl6 t/070-run-command.t
===SORRY!===
P6M Merging GLOBAL symbols failed: duplicate definition of symbol C-MD5-SIZE

Searching for the symbol gave me exactly one location where it was 
defined. So the error should be more explicit in where it was first 
found and where the second throws the error.


Marcel Timmerman


Bug returning objects directly from called methods using some form of named arguments

2015-10-26 Thread mt1957

Two samples of code for which the problem is closely related

The first problem;

  return MongoDB::Cursor.new(
collection  => self,
OP_REPLY=> $OP_REPLY,
criteria=> %@criteria
  );

Generates the error; 'Default constructor for 'MongoDB::Cursor' only 
takes named arguments'



The second problem;

  return self.find-and-modify(
$criteria, $projection, :$remove, :$update, :$sort,
:$new, :$upsert
  );

Generates: 'Too many positionals passed; expected 1 to 3 arguments but 
got 8'




To make it work I had to resort to the following.

  my $c = MongoDB::Cursor.new(
collection  => self,
OP_REPLY=> $OP_REPLY,
criteria=> %@criteria
  );

  return $c;


and for the second the same way

  my $h = self.find-and-modify(
$criteria, $projection, :$remove, :$update, :$sort,
:$new, :$upsert
  );

  return $h;

perl6 version 2015.09-346-g0251b52 built on MoarVM version 
2015.09-74-gedc44b5


Greetings
Marcel Timmerman



delegation

2015-10-07 Thread mt1957

Hi,

According to synopsis 12 I could defer methods to methods in another object.
The case in which one can map some name into another didn't work out.
*
**
**class A {**
**  method say-i (Int $i ) { say "I: $i"; }**
**}**
**
**class B {**
**  has A $.n handles { :x };**
**
**  submethod BUILD { $!n .= new; }**
**}**
**
**my B $b .= new;**
**$b.x(30);**
*

Error is
Method 'x' not found for invocant of class 'A'

OK, then I misunderstood it but when flipping the key value map in that 
particular line like so


*  has A $.n handles { :say-i };*

Error is now
Method 'x' not found for invocant of class 'B'

Removing brackets from the first try works
*  has A $.n handles :x;**
**
*As well as
*  has A $.n handles (:x);**
*
Conclusion is that curly brackets for Hash does not work while Pair's do.
Hashes aren't tested either. See|S12-attributes/delegation.t| lines 
|65–80| 
 



Greetings,
Marcel


type mistakes creating unhelpful error messages

2015-10-03 Thread mt1957

In great need of proper message ...

I have a bad habit of writing defined/undefined(:D or :U) constraint 
after the variable instead of after the type before the variable in a 
call signature(Don't ask why ;-|).


The error given is

Cannot invoke this object

Perl is not able to parse the object to find the line where it happens

Greets
Marcel


Re: grep changes?

2015-10-02 Thread mt1957

Hi Philip,

Thanks for your answer. Seems that I've written it wrongly then. Doesn't 
the block get the topic variable in the same way like map or can't the 
block be used there at all?


Greetings
Marcel
Grep still accepts a regex, so `grep /\.pl6/, ` does what 
you want.


On Fri, Oct 2, 2015 at 5:12 PM mt1957 <mailto:mt1...@gmail.com>> wrote:


Hi,
noticed that grep doesn't accept a Match operation anymore
In repl ...

 > grep { /\.pl6/ },  
Method 'match' not found for invocant of class 'Any'

Must now do explicitly match on the topic variable

 > grep { $_ ~~ /\.pl6/ },  
(a.pl6)

Is this change correct?

perl6 version 2015.09-206-g8a195fa built on MoarVM version
2015.09-39-g1434283

Greets,
Marcel





grep changes?

2015-10-02 Thread mt1957

Hi,
noticed that grep doesn't accept a Match operation anymore
In repl ...

> grep { /\.pl6/ },  
Method 'match' not found for invocant of class 'Any'

Must now do explicitly match on the topic variable

> grep { $_ ~~ /\.pl6/ },  
(a.pl6)

Is this change correct?

perl6 version 2015.09-206-g8a195fa built on MoarVM version 
2015.09-39-g1434283


Greets,
Marcel


Re: [perl #126212] [BUG] SEGV on 16-bit-sized arg insertion

2015-09-29 Thread mt1957

On 09/28/2015 06:52 PM, Larry Wall (via RT) wrote:

# New Ticket Created by  Larry Wall
# Please include the string:  [perl #126212]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=126212 >


09:24 < TimToady> m: say 1, |(2 xx 65534)
09:24 <+camelia> rakudo-moar cd8ce4: OUTPUT«(signal SEGV)»

It works fine until 49151 which is 0xbfff
Fails after 49152 (0xc000)



Re: Bug creating objects using some form of named arguments

2015-09-29 Thread mt1957
The trouble I get at the moment is an error generared by the following 
piece of code


  return MongoDB::Cursor.new(
collection  => self,
OP_REPLY=> $OP_REPLY,
criteria=> %@criteria
  );

It generates the error;

Default constructor for 'MongoDB::Cursor' only takes named arguments
  in method throw at 
/home/marcel/Software/lib/perl6/share/perl6/runtime/CORE.setting.moarvm:1

...

In the previous mails I've tried to golf it but failed, so there is 
something in my programs which triggers this error but I don't know 
where and why.


I could solve it by using other named parameter formats but the 
following code rewrite (which now doesn't error) seems to point to the 
combination with the return statement;


  my $c = MongoDB::Cursor.new(
collection  => self,
OP_REPLY=> $OP_REPLY,
criteria=> %@criteria
  );

  return $c;

perl6 version 2015.09-162-gdd6c855 built on MoarVM version 
2015.09-39-g1434283


Greetings
Marcel Timmerman



Re: Bug creating objects using some form of named arguments

2015-09-28 Thread mt1957

On 09/28/2015 07:16 PM, mt1957 wrote:

False alarm, had a typing error in the code so, mea culpa poli :-[ .



Hi

Below a set of tests where all object creates are done well except for 
the last one using a sub or method returning the created object.



class X {
  has Str $.a;
}

my X $x .= new(a => 'abc');
say "\$x = {$x.perl}";

$x .= new(:a('abc'));
say "\$x = {$x.perl}";

$x .= new :a('abc');
say "\$x = {$x.perl}";

$x .= new :a;
say "\$x = {$x.perl}";

class X::Y {
  has Str $.a;
  has Str $.b;
}

my  $y = X::Y.new(
  a => 'abc',
  b => 'def'
);
say "\$y = {$y.perl}";

$y .= new( :a('abc'), :b('def'));
say "\$y = {$y.perl}";

$y .= new :a('abc') :b('def');
say "\$y = {$y.perl}";

$y .= new :a :b;
say "\$y = {$y.perl}";



my X::Y $z = xy( );
say "\$z = {$z.perl}";

sub xy ( Str $s1, Str $s2 --> X::Y ) {
  return X::Y.new(
a => 'abc',
b => 'def'
  );
}


The output and error returned is

$x = X.new(a => "abc")
$x = X.new(a => "abc")
$x = X.new(a => "abc")
$x = X.new(a => "abc")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
Too few positionals passed; expected 2 arguments but got 1
  in sub xy at named-parameters.pl6:46
  in block  at named-parameters.pl6:43


I have to explicitly rewrite it into one of the colon forms (';')

my  $y = X::Y.new(
  :a('abc'),
  :b('def')
);

Greets,
M




Bug creating objects using some form of named arguments

2015-09-28 Thread mt1957

Hi

Below a set of tests where all object creates are done well except for 
the last one using a sub or method returning the created object.



class X {
  has Str $.a;
}

my X $x .= new(a => 'abc');
say "\$x = {$x.perl}";

$x .= new(:a('abc'));
say "\$x = {$x.perl}";

$x .= new :a('abc');
say "\$x = {$x.perl}";

$x .= new :a;
say "\$x = {$x.perl}";

class X::Y {
  has Str $.a;
  has Str $.b;
}

my  $y = X::Y.new(
  a => 'abc',
  b => 'def'
);
say "\$y = {$y.perl}";

$y .= new( :a('abc'), :b('def'));
say "\$y = {$y.perl}";

$y .= new :a('abc') :b('def');
say "\$y = {$y.perl}";

$y .= new :a :b;
say "\$y = {$y.perl}";



my X::Y $z = xy( );
say "\$z = {$z.perl}";

sub xy ( Str $s1, Str $s2 --> X::Y ) {
  return X::Y.new(
a => 'abc',
b => 'def'
  );
}


The output and error returned is

$x = X.new(a => "abc")
$x = X.new(a => "abc")
$x = X.new(a => "abc")
$x = X.new(a => "abc")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
$y = X::Y.new(a => "abc", b => "def")
Too few positionals passed; expected 2 arguments but got 1
  in sub xy at named-parameters.pl6:46
  in block  at named-parameters.pl6:43


I have to explicitly rewrite it into one of the colon forms (';')

my  $y = X::Y.new(
  :a('abc'),
  :b('def')
);

Greets,
M


error message about here doc

2015-09-28 Thread mt1957
Using a heredoc and by accident adding '#' unindented, generated the 
following error;


Asked to remove 2 spaces, but the shortest indent is 0 spaces in any 
trim_heredoc at gen/moar/m-Perl6-Actions.nqp:78


The here doc used was;

spurt 'Sandbox/m-auth.conf', $config ~ qq:to/EOCNF/;

  security:
#keyFile:m.key-file
#clusterAuthMode:keyFile
authorization:  enabled

  setParameter:
enableLocalhostAuthBypass:  false

  EOCNF


While the message was correct it didn't say where it happened (in my 
code that is).


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


Greets,
M


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



Misunderstanding when usng elems on undefined Array

2015-09-25 Thread mt1957

Found the following using Array;

> my Array $a;
> say $a.elems;
1
> $a.push(1)
[1]
> say $a.perl
[1]
> say $a.elems
1


> my Array $a .= new;
[]
> say $a.elems;
0

Seems that an uninitialized Array reports one element but pushing values 
on the array will define the properly. In this case it is important to 
initialize.


Perl version:  2015.09-95-g3970634 built on MoarVM version 
2015.09-35-gd15a446


Greetings
Marcel Timmerman


Problem detecting identifiers in some grammar rules

2015-09-02 Thread mt1957

Problem is found in the following piece of code;

3  grammar Grammar {
4rule TOP { <.sentence>+ }
5rule sentence { ('c1'|'c2') '=' <+ dutch-chars - [aeiou]>+ }
6token dutch-chars { <[a..z]> }
7  }

Grammar.parse('c1 = sdwbh') ~~ Match || say 'Matched dutch characters';

Error message is;

Method 'chars' not found for invocant of class 'Grammar'
  in regex sentence at Regex3.pl6:5
  in regex TOP at Regex3.pl6:4
  in block  at Regex3.pl6:9

Changing 'dutch-chars' into 'dutch_chars' will compile fine. Seems that 
the dash in between is seen as a substraction.


Perl6 version 2015.07.1-182-g5ba44fc built on MoarVM version 
2015.07-108-g7e9f29e


Greetings
Marcel Timmerman


bufs and utf8

2015-08-31 Thread mt1957

Hi,

I can not do the following;
my Buf $b = 'abc'.encode;
Type check failed in assignment to '$b'; expected 'Buf' but got 'utf8'

But I can do this;
my Buf $b = 'abc'.encode ~ Buf.new();
Buf:0x<61 62 63>

Does the concatenation convert utf8 into Buf? Will there be a problem 
when it is converted back to string
with decode. I've tested a few simple utf strings which seem to decode 
right.


Greetings
Marcel


user programming mistakes

2015-08-03 Thread mt1957

Hi,

I there a way to prevent some type of mistake I now have made several 
times merely because the error messages are not helping me to point to 
the problem.


Example;

  grammar Turtle::Grammar {
rule TOP { * }

...

rule directive {  |  }

...

rule base {
  '@base'* 
}

...

For this piece of grammar I get the message something like;

Too many positionals passed; expected 1 argument but got 2
 in regex base at 
/home/marcel/Languages/Perl6/Projects/Rdf/lib/Rdf/Turtle/Grammar.pm6:41


So what would that mean Only after some while I remembered that 
there is a base() method which gets called here and I needed to change 
the targets from base to e.g. base-id. After that all went fine.


I had this once before where I had declared a whitespace target  
which is already defined. Also with strange results.


Somehow there must be a way to test when there is a redefinition of 
sorts going on.


Greetings,
Marcel




spectest fail

2015-06-20 Thread mt1957

l.s.

Just to mention...

Spectest 'S17-supply/start.t' fails on my system.

$ uname -a
Linux h03-fedora 3.19.8-100.fc20.x86_64 #1 SMP Tue May 12 17:08:50 UTC 
2015 x86_64 x86_64 x86_64 GNU/Linux


$ perl6 -v
This is perl6 version 2015.06-22-g70c5bc5 built on MoarVM version 
2015.06-16-g46e941c



$ prove -v -e perl6 t/spec/S17-supply/start.t
t/spec/S17-supply/start.t ..
1..9
ok 1 - can not be called as a class method
ok 2 - Did we get a master Supply?
ok 3 - Did we get a starter Supply?
ok 4 - Did we get a Tap
ok 5 - did we get a supply?
ok 6 - did we get a tap?
ok 7 - did we get two extra supplies?
ok 8 - did we get two extra taps?
not ok 9 - did we get the other original value

# Failed test 'did we get the other original value'
# at t/spec/S17-supply/start.t line 34
# expected: [1, 1]
#  got: [1]
# Looks like you failed 1 test of 9
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/9 subtests

Test Summary Report
---
t/spec/S17-supply/start.t (Wstat: 256 Tests: 9 Failed: 1)
  Failed test:  9
  Non-zero exit status: 1
Files=1, Tests=9,  2 wallclock secs ( 0.02 usr  0.00 sys + 0.27 cusr  
0.08 csys =  0.37 CPU)

Result: FAIL

Greetings,
Marcel


Re: Problem documentation and/or compiler

2015-06-18 Thread mt1957
Sorry I've been too fast, It's in the doc. However, why can't I assign 
it to a Buf with automatic coercion from utf8 to Buf which is more generic?


Marcel

On 06/18/2015 11:12 AM, mt1957 wrote:

L.s.

At http://doc.perl6.org/type/Str#method_encode it says that string 
encoding returns a Buf.

It returns a utf8 instead see repl session below.

> my Str $s = 'abcdef';
abcdef
> my Buf $b = $s.encode;
Type check failed in assignment to '$b'; expected 'Buf' but got 'utf8'
  in block  at :1


Marcel






Problem documentation and/or compiler

2015-06-18 Thread mt1957

L.s.

At http://doc.perl6.org/type/Str#method_encode it says that string 
encoding returns a Buf.

It returns a utf8 instead see repl session below.

> my Str $s = 'abcdef';
abcdef
> my Buf $b = $s.encode;
Type check failed in assignment to '$b'; expected 'Buf' but got 'utf8'
  in block  at :1


Marcel




panda install problem

2015-06-17 Thread mt1957

l.s.

I am having a problem installing my BSON package with panda locally. It 
fails when it compiles the files to moarvm using perl6 version 
2015.05-186-g15c6fbf built on MoarVM version 2015.05-74-gc14339c.


$ panda install .

==> Installing BSON from a local directory '.'
==> Fetching BSON
==> Building BSON
Compiling lib/BSON/ObjectId.pm to mbc with 
/home/marcel/Software/lib/perl6/bin/perl6
Compiling lib/BSON/Regex.pm to mbc with 
/home/marcel/Software/lib/perl6/bin/perl6
Compiling lib/BSON/Javascript.pm to mbc with 
/home/marcel/Software/lib/perl6/bin/perl6
Compiling lib/BSON/Binary.pm to mbc with 
/home/marcel/Software/lib/perl6/bin/perl6

Compiling lib/BSON.pm to mbc with /home/marcel/Software/lib/perl6/bin/perl6
===SORRY!===
Missing or wrong version of dependency '$et' (from 'lib/BSON/Binary.pm')
==> Test report submitted as: http://testers.perl6.org/reports/.html
build stage failed for BSON: Failed building lib/BSON.pm
  in method install at lib/Panda.pm:128
  in method resolve at lib/Panda.pm:214
  in sub MAIN at /home/marcel/Software/lib/perl6/bin/panda:20
  in block  at /home/marcel/Software/lib/perl6/bin/panda:87


Failure Summary

.
*build stage failed for BSON: Failed building lib/BSON.pm


 I've inserted a few lines in the panda Builder.pm to see the command 
it is using. Then I've repeated that command myself (Created a directory 
Blib/lib for it) and perl6 runs it without a failure. So, what happens 
above


$ /home/marcel/Software/lib/perl6/bin/perl6 --target=mbc 
--output=blib/lib/BSON.pm.moarvm lib/BSON.pm


I can't see what I can do to remedy this.
I've upgraded perl6 to version 2015.05-202-g9b1e856 built on MoarVM 
version 2015.05-79-g458940f. Also I use the latest panda version


Greetings,
Marcel



Re: [perl #125400] Fwd: problem pushing pairs onto an array of pairs

2015-06-15 Thread mt1957

On 06/13/2015 04:06 PM, Elizabeth Mattijsen (via RT) wrote:

Hi,
May I react on this? Would it be easier to have perl6 throw an error 
when there is a named parameter in the call while it isn't defined in 
the method. Something like 'Named parameter 'x' not defined by push' in 
the example set below. It would start me thinking... It would in any 
case be better than saying nothing.



# New Ticket Created by  Elizabeth Mattijsen
# Please include the string:  [perl #125400]
# in the subject line of all future correspondence about this issue.
# https://rt.perl.org/Ticket/Display.html?id=125400 >


I’m sending this in as a rakudo bug because I think it is.

We have confusion about what is a Pair and what is a named parameter.  I see 
just about everybody fall into this trap.

The only way I see around this, is to separate the meaning of Pair and named 
parameter visually as well:

a => 42 # a Pair
:a(42)  # a named parameter

I could also see going as far as making a named parameter an Enum, or a(nother) 
subclass of it.


Liz
===

Begin forwarded message:

Date: 13 Jun 2015 04:25:43 GMT-6
From: mt1957 
To: perl6 users 
Subject: problem pushing pairs onto an array of pairs

l.s.

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

Below a repl session with pushes


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

a => 1 b => 2

@p.push(x=>1);

a => 1 b => 2


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

a => 1 b => 2

@p.push(x=>1);

a => 1 b => 2



my Array $p = [ a => 1, b => 2];

a => 1 b => 2

$p.push(x=>1);

a => 1 b => 2


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

a => 1 b => 2

@p.push(Pair.new(x=>1));

a => 1 b => 2 (Any) => (Mu)

In all cases the pair x=>1 is not added. The last case is weird to me.

greetings,
Marcel





Re: problem pushing pairs onto an array of pairs

2015-06-13 Thread mt1957

Hi Eirik,

I thought about this a bit longer. I've seen this before that typo's in 
the named arguments can lead to things for which you think would happen 
but they don't. proper testing should reveal this of course. But it 
would also be nice that an error would be given by perl6 and we would 
have known that there was a typo or in the case below a wrong argument 
to the push method. Something like 'named attribute x not recognized'.


Greets,
Marcel

On Sat, Jun 13, 2015 at 12:25 PM, mt1957 <mailto:mt1...@gmail.com>> wrote:


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

Below a repl session with pushes

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

a => 1 b => 2

@p.push(x=>1);

a => 1 b => 2


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


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


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


Eirik




problem pushing pairs onto an array of pairs

2015-06-13 Thread mt1957

l.s.

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

Below a repl session with pushes


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

a => 1 b => 2

@p.push(x=>1);

a => 1 b => 2


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

a => 1 b => 2

@p.push(x=>1);

a => 1 b => 2



my Array $p = [ a => 1, b => 2];

a => 1 b => 2

$p.push(x=>1);

a => 1 b => 2


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

a => 1 b => 2

@p.push(Pair.new(x=>1));

a => 1 b => 2 (Any) => (Mu)

In all cases the pair x=>1 is not added. The last case is weird to me.

greetings,
Marcel



panda seeing duplicate symbol definitions

2015-06-09 Thread mt1957

l.s.

Installing the BSON module gives the following fault when it runs the 
tests. It fails in t/700-encodable.t as shown below


$ panda install BSON
...
t/100-double.t . ok
t/101-binary.t . ok
t/102-int.t  ok
t/500-native.t . ok
t/600-extended.t ... ok
===SORRY!===
Merging GLOBAL symbols failed: duplicate definition of symbol Encodable
t/700-encodable.t ..
No subtests run
t/701-decoder.t  ok
t/703-encodable.t .. ok
...

Locally testing with prove does not reveil such a problem. In the test 
file there is made use of to modules BSON::Encodable and BSON::Double. 
The problem for panda is presumably that BSON::Double also uses 
BSON::Encodable.


For the moment I've shortened the test and inserted a comment '#' before 
the use of that

module.

Greets,
Marcel Timmerman



Re: Problem found with PERL6LIB environment variable

2015-06-08 Thread mt1957

On 06/08/2015 09:24 PM, Tobias Leich wrote:

say $*DISTRO.cur-sep



Hi Tobias,

It returns a comma.

I've used this in the path and processing is now ok. I was stuck with 
panda unable to do anything. As a workaround I can continue now. 
Hopefully this separator will be set back to ':' again.


Greets,
Marcel


panda occurrence of deprecated code message

2015-06-08 Thread mt1957

l.s.

Running newest panda code on newest perl6 (This is perl6 version 
2015.05-139-g2281689 built on MoarVM version 2015.05-49-g07fbd62).


$ panda list
...

Method for (from Any) seen at:
  /home/marcel/Software/Packages/panda/lib/Panda/App.pm, lines 51,54
Deprecated since v2015.5, will be removed with release v2015.9!
Please use flatmap instead.


Marcel Timmerman


Problem found with PERL6LIB environment variable

2015-06-08 Thread mt1957

ls,

Found another problem in the new rakudo (understood that was from 4/8). 
Version: 'This is perl6 version 2015.05-139-g2281689 built on MoarVM 
version 2015.05-49-g07fbd62'


It seems that perl6 doesn't understand the environment variable PERL6LIB 
anymore.

Example (in tcsh shell);

$ setenv PERL6LIB ".:lib:/home/marcel/Software/lib/perl6/lib"
$ perl6 some-program.pl6
some-program.pl6 .. ===SORRY!===
Could not find Semi-xml in any of:
  file#.:lib:/home/marcel/Software/lib/perl6/lib
  file#/home/marcel/.perl6/2015.05-139-g2281689/lib
  inst#/home/marcel/.perl6/2015.05-139-g2281689
  file#/home/marcel/Software/lib/perl6/share/perl6/lib
  file#/home/marcel/Software/lib/perl6/share/perl6/vendor/lib
  file#/home/marcel/Software/lib/perl6/share/perl6/site/lib
  inst#/home/marcel/Software/lib/perl6/share/perl6
  inst#/home/marcel/Software/lib/perl6/share/perl6/vendor
  inst#/home/marcel/Software/lib/perl6/share/perl6/site

You can find the PERL6LIB text back in the first line of the error 
message. It isn't split on the colon to get multiple paths.


Greetings,
Marcel Timmerman



Problem found with PERL6LIB environment variable (cont)

2015-06-08 Thread mt1957

ls,

Also seems to go wrong for RAKUDOLIB
Example (in tcsh shell);

$ setenv RAKUDOLIB ".:lib:/home/marcel/Software/lib/perl6/lib"
$ setenv PERL6LIB ".:lib:/home/marcel/Software/lib/perl6/lib"
$ perl6 some-program.pl6
some-program.pl6 .. ===SORRY!===
Could not find Semi-xml in any of:
  file#.:lib:/home/marcel/Software/lib/perl6/lib
  file#.:lib:/home/marcel/Software/lib/perl6/lib
  file#/home/marcel/.perl6/2015.05-139-g2281689/lib
  inst#/home/marcel/.perl6/2015.05-139-g2281689
  file#/home/marcel/Software/lib/perl6/share/perl6/lib
  file#/home/marcel/Software/lib/perl6/share/perl6/vendor/lib
  file#/home/marcel/Software/lib/perl6/share/perl6/site/lib
  inst#/home/marcel/Software/lib/perl6/share/perl6
  inst#/home/marcel/Software/lib/perl6/share/perl6/vendor
  inst#/home/marcel/Software/lib/perl6/share/perl6/site

Now both aren't split on the colon to get multiple paths.

Greetings,
Marcel Timmerman



Scheduler problem with scheduled events

2015-05-02 Thread mt1957

L.s.

Reading though synopsis S17 concurrency I tried the following

$*SCHEDULER.cue: in=>10, { say "10s later" }

which will deliver the string after 10 seconds. However the moar will 
work like hell at a 100% cpu time before and afterwards! Removing the 
option 'in' didn't show this problem.


Another option will show the same problem in the following code.

my $c = $*SCHEDULER.cue: :every(1), { say "Oh wow, a kangaroo!" };
sleep 10;
$c.cancel;

Canceling will stop the output of kangaroos but moar will keep on doing 
its thing at about 100% cpu time. I didn't found an option or method to 
stop that thread.



I am working with perl6 version 2015.04-5-g59f57a8 built on MoarVM 
version 2015.04-3-gbb50941


Greetings,
Marcel


class/role problem

2015-04-27 Thread mt1957

Ls,

Following piece of code gets an error when calling $b.get-t0.
---
#!/usr/bin/env perl6
#
use v6;

role A {
  has $!t0;

  method get-t0 ( ) {
return self!get-t0-helper;
  }

  method !get-t0-helper ( ) {
my $t0 = $!t0 // 'T0';
  }
}

class B does A {  }

my $a = A.new;
say "A: ", $a.get-t0;

my $b = B.new;
say "B: ", $b.get-t0;
---

The output and error is;

Attr: Int $!t0
A: T0
Attr: Int $!t0
P6opaque: no such attribute '$!t0'
  in method get-t0-helper at class3.pl6:14
  in method get-t0 at class3.pl6:9
  in block  at class3.pl6:25

The strange thing is when you call self.^attributes in the helper method 
the name is printed as shown in the output. The error disappears after 
removing the hide(!) operator.


Perl version;
This is perl6 version 2015.04-5-g59f57a8 built on MoarVM version 
2015.04-3-gbb50941


Greetings,
Marcel




class and its object variables

2015-04-23 Thread mt1957

L.s.

The following piece of code shows that one must be careful using my or 
state variables in a class. They have the same behavior as an our 
variable if I am right. Are they all kind of global to the class/object?

---
class A {

  my $a;
  has $.a;
  our $p;
  state $q;

  method set ($b) {
$a = $b;
$!a = $b+10;
$p = $b+20;
$q = $b+30;
  }

  method get {
$!a //= 'undefined';
return "my=$a, has=$!a, our=$p, state=$q";
  }
}

my $x = A.new;
$x.set(2);  # Set variables in x object
say "X: ", $x.get;

my $y = A.new;
say "Y: ", $y.get;  # Only attribute undefined
$y.set(4);  # Set variables in y object
say "X: ", $x.get;# Modified in $x except for the attribute
---


The results are;

X: my=2, has=12, our=22, state=32
Y: my=2, has=undefined, our=22, state=32
X: my=4, has=12, our=24, state=34

Only the attribute is kept local to the object but all other variables 
are shared between $x and $y.


Should one use only attributes in a class and use our variables to share 
between objects?


Marcel



class/object variables

2015-04-23 Thread mt1957

L.s.

The following piece of code shows that one must be careful using my or 
state variables in a class. They have the same behavior as an our 
variable if I am right. Are they all kind of global to the class/object?

---
class A {

  my $a;
  has $.a;
  our $p;
  state $q;

  method set ($b) {
$a = $b;
$!a = $b+10;
$p = $b+20;
$q = $b+30;
  }

  method get {
$!a //= 'undefined';
return "my=$a, has=$!a, our=$p, state=$q";
  }
}

my $x = A.new;
$x.set(2);  # Set variables in x object
say "X: ", $x.get;

my $y = A.new;
say "Y: ", $y.get;  # Only attribute undefined
$y.set(4);  # Set variables in y object
say "X: ", $x.get;# Modified in $x except for the attribute
---


The results are;

X: my=2, has=12, our=22, state=32
Y: my=2, has=undefined, our=22, state=32
X: my=4, has=12, our=24, state=34

Only the attribute is kept local to the object but all other variables 
are shared between $x and $y.


Should one use only attributes in a class and use our variables to share 
between objects?


Marcel



Grammars

2015-04-19 Thread mt1957

L.s.,

I found a small problem when writing a piece of grammar. A simplified 
part of it is shown here;

...
token tag-body   {  ~   }
token body-start { '[' }
token body-end  { ']' }
token body-text  { .*?  }
...

I needed to do something on body-end so I wrote a method for it using an 
actions class and it works of course but in this situation the method is 
called twice. One time to say there is a 'body-end' coming and one time 
to say it is gobbled up. Because I couldn't see in the method which 
situation it was called for I had to rewrite it like below

...
token tag-body   {  ~   }
token body-start { '[' }
token body-end   { ']' }
token body-text  { .*?  }
token body-end2 { ']' }
...
which is less elegant. The question is more or less directed to a perl6 
implementer;


 * Is there a possibility to give the method more information in the
   form of boolean flags saying for example that there was a look ahead
   match, all in all the parser knows about the way it must seek!

Thanks in advance,
Marcel Timmerman



  1   2   >