Re: initializing Pointer

2023-12-23 Thread Marcel Timmerman
(perhaps already received but I'd got an error back saying '*Delivery 
has failed to these recipients or groups*' from.outl...@ifdog.com, So 
here it comes again.)





Thanks Elizabeth and Todd;

I will set up my own pointer routine, something like this

method make-pointer ( $type, $value ) {
  my $array = CArray[$type].new($value);
  nativecast( Pointer[$type], $array)
}

I forgot the way to make the method type depended and how to search for 
it in the docs.


Regards,
Marcel


Re: initializing Pointer

2023-12-21 Thread Marcel Timmerman

Thanks Elizabeth and Todd;

I will set up my own pointer routine, something like this

method make-pointer ( $type, $value ) {
  my $array = CArray[$type].new($value);
  nativecast( Pointer[$type], $array)
}

I forgot the way to make the method type depended and how to search for 
it in the docs.


Regards,
Marcel


initializing Pointer

2023-12-20 Thread Marcel Timmerman

Hi,

I would like to initialize a Pointer with some value but get an error. 
For example;


my $a = Pointer[Str].new('text');

The error thrown:

Default constructor for 'NativeCall::Types::Pointer[Str]' only takes 
named arguments


The way I can do it now is by creating a CArray and then do a nativecast 
which is a bit cumbersome.
The reason I would like to use Pointers is when there is only one object 
to point to, not an array. Secondly, for the use of the deref() function 
to get the value it points to.


Is there another way to solve this or is it a bug in the 
NativeCall::Types module. I have noticed that there  are 3 new() methods 
defined accepting positional arguments.


Regards,
Marcel



Re: Raku regex assert doesn't match

2023-07-30 Thread Marcel Timmerman

On 30-07-2023 06:21, Darren Duncan wrote:

Hello, I have a Raku regex question.

See the following:

    token nonquoted_alphanumeric_text
    {
    >
    <[ A..Z _ a..z ]> <[ 0..9 A..Z _ a..z ]>*
    }

What I want is for "nonquoted_alphanumeric_text" to match any simple 
ASCII bareword EXCEPT a few special cases indicated in the example.


I was hoping there might be some better way of specifying this than my 
example.


Is there any more direct way in Raku to say, match this pattern 
initially, but if the result equals these exceptional values then 
treat it as having not matched.


I am looking for a fully declarative solution in the grammar itself, 
not something involving post-processing.


Thank you.

-- Darren Duncan


You can try: <|wb>*



(From: 
https://docs.raku.org/language/regexes#Predefined_character_classes)




Re: Help with %?RESOURCES variable

2023-04-20 Thread Marcel Timmerman

On 17-04-2023 18:01, David Santiago wrote:

sub MAIN(){
say %?RESOURCES{"text.txt"}.slurp(:close);
}


If you really want to use it from a MAIN you could make a lookup method 
in a module which can do the work for you (If  you are building modules 
anyway).


use AModule;

sub MAIN(){
say AModule.new.lookup{"text.txt"}.slurp(:close);
}

#---
unit class AModule;

method lookup ( $needle --> Str ) {
%?RESOURCES{$needle}
}


I think you also do not need a '.new' here and also may define an 
exported sub


Marcel



Re: New doc site

2023-02-27 Thread Marcel Timmerman

On 27-02-2023 01:08, Will Coleda wrote:

Since I know not everyone is on IRC:

The updated raku.docs.org site is now live! Big thanks to everyone who
helped make this happen!

If you find any issues please let me know at

https://github.com/raku/doc/issues - content

https://github.com/raku/doc-website/issues - site, search, styling, etc.

Hi Will,

Thanks for all the effort you and all writers/debuggers have put into it.
A small typo above though; 'raku.docs.org' should be 
'https://docs.raku.org/'.  However, I could find it via the weekly post 
of Elizabeth.


Thanks again,
Marcel


Re: What is this "\t"?

2022-11-29 Thread Marcel Timmerman

On 29-11-2022 15:08, Elizabeth Mattijsen wrote:
Perhaps it would make sense to export these to a separate 
Gnome::Constants module?
Wel, I have done that, sort of. The file is generated in the Build phase 
of the installation of Gnome::N where I run a C program outputting the 
sizes from several C macro definitions. The other types are fixed, like 
gboolean and just added to the list. The file is called 
Gnome::N::GlibToRakuTypes.





On 29 Nov 2022, at 15:05, Marcel Timmerman  wrote:

On 29-11-2022 10:13, Francis Grizzly Smit wrote:

Hi Francis,
Personally I never use \name are I hate how it looks, and so far I 
have never needed it, so unless I can find something it can do that 
I cannot do any other way, I'll keep on not using it


To show an example where I could use it I have defined a series of 
types in the Gnome packages of mine and could then use it everywhere 
as a type. The glib has several types defined which I wanted to use 
in my code so that I can cut and paste the code from the C source 
into Raku source without much changes.


There is a file defined in Gnome::N where a list of types is defined
…
constant \gboolean is export = int32;
constant \gchar is export = int8;
constant \gdouble is export = num64;
constant \gfloat is export = num32;
constant \gint is export = int32;
…


And later in other modules I could then use these definitions, here 
for example 'gint'.


…
sub gtk_widget_add_events (
N-GObject $widget, gint $events
) is native(>k-lib)
{ * }
…

The types file is generated to cope with int sizes differing on 
several implementations. E.g. a long int could be 32 or 64 bits 
depending on the implementation or OS or chip or ….







Re: What is this "\t"?

2022-11-29 Thread Marcel Timmerman

On 29-11-2022 10:13, Francis Grizzly Smit wrote:

Hi Francis,


Personally I never use \name are I hate how it looks, and so far I 
have never needed it, so unless I can find something it can do that I 
cannot do any other way, I'll keep on not using it


To show an example where I could use it I have defined a series of types 
in the Gnome packages of mine and could then use it everywhere as a 
type. The glib has several types defined which I wanted to use in my 
code so that I can cut and paste the code from the C source into Raku 
source without much changes.


There is a file defined in Gnome::N where a list of types is defined
…
constant \gboolean    is export = int32;
constant \gchar   is export = int8;
constant \gdouble is export = num64;
constant \gfloat  is export = num32;
constant \gint    is export = int32;
…


And later in other modules I could then use these definitions, here for 
example 'gint'.


…
sub gtk_widget_add_events (
  N-GObject $widget, gint $events
) is native(>k-lib)
  { * }
…

The types file is generated to cope with int sizes differing on several 
implementations. E.g. a long int could be 32 or 64 bits depending on the 
implementation or OS or chip or ….




Re: author specification

2022-05-04 Thread Marcel Timmerman

Hi Vadim,
I'd put it this way: this API has not been stabilized yet. Though at 
the moment it's coming to some consensus.
Hopefully it would not be necessary to change the auth field which is 
the main issue of mine. Because fez is registering the user on its first 
run, the auth field is not needed to find the username later on.


Come to think of it, starting the auth field with 'fez' when it is 
stored on the fez ecosystem, cpan on the cpan system, etc. is 
information which is redundant. fez is checking the ecosystems one by 
one to find distributions just to find an auth starting with the same 
name as the ecosystem it is accessing.


Currently the only ecosystem with authentication is zef. In order to 
publish there fez would ask your password once in a while. This is 
also why all other ecosystems are considered deprecated.
I still have some trouble with fez just because of this auth field I 
think. There are others with the same issue.



Best regards,
Vadim Belman


Thanks for your information, I'll wait for its outcome,
Regards,
Marcel



On May 3, 2022, at 11:59 AM, Marcel Timmerman  wrote:

Hi Brad,

Auth is for more than just the author. It is for author, authority, 
and authentication.
There is no password or other cryptographic way, so authentication is 
not possible. Obviously, I might miss some insight here.


In the documentation I read; "|:auth| generally takes the form 
|hosting:ID|, as in |github:github-user| or |gitlab:gitlab-user|". 
For me, hosting is e.g. on GitHub or Gitlab to store the software, 
and ecosystems are for spreading the word, i.e. telling that there is 
a software available somewhere, and this somewhere is not important. 
That is the work for zef to find out.


And the word 'generally' means that it is just an example, it is in 
the end just a string.
Furthermore, there is no mention in the docs of any use other than 
naming it in a useful way. No remarks of needing it to login into 
some ecosystem and no word about that separator, being a column, or 
split it up in more than two fields using an other character.


Searching through some distributions I find 'zef:lizmat', 
'github:MARTIMM', 'tonyo', 'cpan:WARRINGD', 'github:ccworld1000, 
ccworld1...@gmail.com, 2291108...@qq.com', showing that there is 
absolutely no clear way to use that field. For me, it means again 
that the auth field must be completely free and the same, independent 
of the ecosystem in use.


CPAN can't authenticate github or fez modules, and vice versa. There 
is a reason the field is only the first four letters.

The word 'github' is longer.

That they are seen as different modules is an intended feature, not 
a bug.

I didn't want to say that it was a bug, sorry for the confusion.

I would like to know how you would want the system to handle a 
module from me. cpan:BGILLS github:b2gills and I intend to get 
b2gills on fez as well. (CPAN doesn't allow numbers, otherwise I 
would have it there to.)
Do you want to write several meta files with different auth fields 
depending on the ecosystem you want to send it to? The only thing you 
can do without much work is sending a project e.g. to fez and another 
to cpan but I don't see the use of spreading your projects over 
several ecosystems.


Also for a class you wrote, JSON::Class, what should I write (I took 
it to the extreme of course, 'use JSON::Class' would do)


use JSON::Class:auth;
use JSON::Class:auth;
use JSON::Class:auth;

All three are getting the same software, or not, when it is someone 
els-es auth.


What if someone else took a user name on github that matched one on 
CPAN or fez?
That is the point I want to make. Keeping the auth field the same 
everywhere, independent of ecosystem, will show that the software is 
the same everywhere. If that someone has the same account name as 
someone else on cpan or fez it will show a difference in the auth field.


So, I think there is a lot to ponder over
Regards,
Marcel



On Mon, May 2, 2022, 3:23 PM Marcel Timmerman  wrote:

Hi,

I was wondering about the 'auth' specification in the meta file
or on the class/module/package. I was used to specify it as
'github:MARTIMM' because I store the stuff on GitHub for all the
goodies it offers. Now I see//that fez wants to start with
'fez:' and when I look at the raku.land site for a module of
mine I see a remark /'/The uploading author of cpan:MARTIMM does
not match the META author of github:MARTIMM.' because I upload
it to CPAN nowadays and have never specified somewhere that the
auth has become 'cpan:MARTIMM'.

I feel that this is not useful (even correct) to pin someone to
use an auth specification with a defined prefix for some
ecosystem one is using. So changing to another ecosystem forces
that perso

Re: author specification

2022-05-03 Thread Marcel Timmerman

Hi Brad,

Auth is for more than just the author. It is for author, authority, 
and authentication.
There is no password or other cryptographic way, so authentication is 
not possible. Obviously, I might miss some insight here.


In the documentation I read; "|:auth| generally takes the form 
|hosting:ID|, as in |github:github-user| or |gitlab:gitlab-user|". For 
me, hosting is e.g. on GitHub or Gitlab to store the software, and 
ecosystems are for spreading the word, i.e. telling that there is a 
software available somewhere, and this somewhere is not important. That 
is the work for zef to find out.


And the word 'generally' means that it is just an example, it is in the 
end just a string.
Furthermore, there is no mention in the docs of any use other than 
naming it in a useful way. No remarks of needing it to login into some 
ecosystem and no word about that separator, being a column, or split it 
up in more than two fields using an other character.


Searching through some distributions I find 'zef:lizmat', 
'github:MARTIMM', 'tonyo', 'cpan:WARRINGD', 'github:ccworld1000, 
ccworld1...@gmail.com, 2291108...@qq.com', showing that there is 
absolutely no clear way to use that field. For me, it means again that 
the auth field must be completely free and the same, independent of the 
ecosystem in use.


CPAN can't authenticate github or fez modules, and vice versa. There 
is a reason the field is only the first four letters.

The word 'github' is longer.


That they are seen as different modules is an intended feature, not a bug.

I didn't want to say that it was a bug, sorry for the confusion.

I would like to know how you would want the system to handle a module 
from me. cpan:BGILLS github:b2gills and I intend to get b2gills on fez 
as well. (CPAN doesn't allow numbers, otherwise I would have it there to.)
Do you want to write several meta files with different auth fields 
depending on the ecosystem you want to send it to? The only thing you 
can do without much work is sending a project e.g. to fez and another to 
cpan but I don't see the use of spreading your projects over several 
ecosystems.


Also for a class you wrote, JSON::Class, what should I write (I took it 
to the extreme of course, 'use JSON::Class' would do)


use JSON::Class:auth;
use JSON::Class:auth;
use JSON::Class:auth;

All three are getting the same software, or not, when it is someone 
els-es auth.


What if someone else took a user name on github that matched one on 
CPAN or fez?
That is the point I want to make. Keeping the auth field the same 
everywhere, independent of ecosystem, will show that the software is the 
same everywhere. If that someone has the same account name as someone 
else on cpan or fez it will show a difference in the auth field.


So, I think there is a lot to ponder over
Regards,
Marcel



On Mon, May 2, 2022, 3:23 PM Marcel Timmerman  wrote:

Hi,

I was wondering about the 'auth' specification in the meta file or
on the class/module/package. I was used to specify it as
'github:MARTIMM' because I store the stuff on GitHub for all the
goodies it offers. Now I see//that fez wants to start with 'fez:'
and when I look at the raku.land site for a module of mine I see a
remark /'/The uploading author of cpan:MARTIMM does not match the
META author of github:MARTIMM.' because I upload it to CPAN
nowadays and have never specified somewhere that the auth has
become 'cpan:MARTIMM'.

I feel that this is not useful (even correct) to pin someone to
use an auth specification with a defined prefix for some ecosystem
one is using. So changing to another ecosystem forces that person
to change the auth everywhere in its code and meta files to get
rid of any errors or warnings. Besides that, the change of the
author on the same code poses the question later on, if that code
is forked and changed by someone else or that it is still the same
developer working on it?

Regards,
Marcel



author specification

2022-05-02 Thread Marcel Timmerman

Hi,

I was wondering about the 'auth' specification in the meta file or on 
the class/module/package. I was used to specify it as 'github:MARTIMM' 
because I store the stuff on GitHub for all the goodies it offers. Now I 
see//that fez wants to start with 'fez:' and when I look at the 
raku.land site for a module of mine I see a remark /'/The uploading 
author of cpan:MARTIMM does not match the META author of 
github:MARTIMM.' because I upload it to CPAN nowadays and have never 
specified somewhere that the auth has become 'cpan:MARTIMM'.


I feel that this is not useful (even correct) to pin someone to use an 
auth specification with a defined prefix for some ecosystem one is 
using. So changing to another ecosystem forces that person to change the 
auth everywhere in its code and meta files to get rid of any errors or 
warnings. Besides that, the change of the author on the same code poses 
the question later on, if that code is forked and changed by someone 
else or that it is still the same developer working on it?


Regards,
Marcel


Re: coercion

2022-02-11 Thread Marcel Timmerman

On 11-02-2022 15:58, Daniel Sockwell wrote:

The question now is that I can't find anything about COERCE in the 
documentation.

Yeah, COERCE definitely should be documented but just hasn't been yet.

There's a raku/doc issue about needing to add it 
(https://github.com/Raku/doc/issues/3807)
but unfortunately none of us has done so yet :(  That issue does link to a 
several blog
posts that explain the new coercion protocol – you might find those useful and 
you or
anyone else might also be able to adapt them into a great doc PR.

-codesections
Thanks Daniel and Liz. I can then continue to deprecate quite some 
methods in favor of the COERCION methods which in the end will make the 
codebase smaller and  perhaps reduce the compile time with it.


I will look into issue 3807 to see what needs to be done.

Many thanks,
Marcel


coercion

2022-02-11 Thread Marcel Timmerman

Hi,

I stumbled over a discussion between Raku developers on 
"Raku/proplem-solving" issue 227 "Coercion reconsidered and unified" and 
I saw something interesting about coercion. Without much knowledge I 
started to experiment with a method called COERCE(). This ended 
successful and can now write, for example, something like


my Gnome::Gdk3::Visual() $visual = $button.get-visual;

which feels more natural instead of

my Gnome::dtk3::Visual $visual .= new(:native-object($button.get-visual));

I can also restrict the coercion like so,

my Gnome::Gdk3::Visual(N-GObject) $visual = …;

The .get-visual() example returns a native object which must be 
encapsulated into the Visual type to access the Visual methods. In the 
Gnome::* libraries are many such calls returning native structures which 
needs to be handled like above to be able to do something with it.



The question now is that I can't find anything about COERCE in the 
documentation. Although I have checked the Raku source code and have 
seen that it is used there, I wonder if this is still experimental Raku 
code and subject to changes.


Regards,
Marcel

pod questions

2021-07-19 Thread Marcel Timmerman

Hi,

Still trying to find a way to have test code in my programs. Normally 
not executed but an imported class could make some sense of it. Others 
have tried already but I wanted to do the following which looks promising;


=begin Gnome-T
=begin code

my Int $i = 10;

=end code
=end Gnome-T


I can find the test code when I process the pod data. The tag added to 
begin will not pose a problem. I need the code section to keep the 
newlines in. The problem now is when one needs to render other pod data 
to html or markdown, this part comes with it like shown the next 
markdown output



Gnome-T
===

    my Int $i = 10;



Three questions;

 * Are there any reserved tags for the '=begin' format name?
 * Reading a bit, I came across old documents (with a warning that
   these are out of date)
   https://design.raku.org/S02.html#Multiline_Comments . It states that
   any unrecognized format name should be treated as a comment block,
   which the above output shows, the renderers do not. Should I file an
   issue?
 * If the block is really treated as comments, would the code block be
   necessary?

Regards,

Marcel



Re: searching for a blog

2021-07-18 Thread Marcel Timmerman

On 7/18/21 4:03 PM, Matthew Stuckwisch wrote:

I think it was Daniel Sockwell (codesections) that played around with it. See the blog 
entry at <https://www.codesections.com/blog/weaving-raku/> and the associated 
Pod::Literate module at 
<https://github.com/codesections/pod-literate/tree/main/lib/Pod> .

There's also my Test::Inline (I know I posted about it somewhere but I don't believe 
it was on a blog) which can be found at 
<https://github.com/alabamenhu/TestInline>, but it doesn't integrate POD6.

Matéu


Matéu, thank you for the links. It wasn't any of these but the last one had a 
link to reddit and at the start there was the link I remembered; 
https://www.codesections.com/blog/raku-unit-testing-with-conditional-compilation/.
 My brain mixed up also on the use of pod docs, instead it was about using DOC 
blocks.

Thanks again,
Marcel





On Jul 18, 2021, at 09:19, Marcel Timmerman  wrote:

Hi,

I am searching for a blog of someone who explained how to write testing code 
next to the programs code. I believe the testing code was written in pod 
documentation. I am interested in the way it was done but can't find the blog 
anymore.

Does anyone have a link to the blog for me?
Thanks,
Marcel




searching for a blog

2021-07-18 Thread Marcel Timmerman

Hi,

I am searching for a blog of someone who explained how to write testing 
code next to the programs code. I believe the testing code was written 
in pod documentation. I am interested in the way it was done but can't 
find the blog anymore.


Does anyone have a link to the blog for me?
Thanks,
Marcel


Re: [naive] hash assingment

2021-07-14 Thread Marcel Timmerman

On 7/14/21 7:43 PM, Aureliano Guedes wrote:

Hi all,

Trying to knowing a little bit more about Raku lang, I decided to 
write a simple (as possible) lib to became similar to R/dplyr or 
Python/Pandas method to data wrangle.


So, Raku gives us the possibility to deal with data in a 
functional way, given the native pipe operator, which is wonderful for 
newbies.

> @a = 1..100
> @a ==> map( { .sqrt } )
> @a ==> HYPER( { .sqrt } ) # faster map
Even it is being *too verbose*, is good enough for the first moment to 
a data scientist.


So I'm trying to decide the best way to abstract columns.
First, I decide to use a hash where the key is the column name and the 
value is the oriented list ou array.


> my %a = {'column1' => [1...5], 'column2' => ['a'...'e']}
Potential difficulties:
    Useless use of hash composer on right side of hash assignment; did 
you mean := instead?

    at line 2
    --> ⏏
{column1 => [1 2 3 4 5], column2 => [a b c d e]}

It is a warning, not an error!

But let's obey the warning.
> my %a = {'column1' := [1...5], 'column2' := ['a'...'e']}
===SORRY!=== Error while compiling:
Cannot use bind operator with this left-hand side
--> n1' := [1...5], 'column2' := ['a'...'e']⏏}


':=' in the error is meant to replace the assignment so you are binding 
directly to the hash.

So write,

my %a := {'column1' => [1...5], 'column2' => ['a'...'e']}

Without the binding you could write instead

my %a = 'column1' => [1...5], 'column2' => ['a'...'e']

See also https://docs.raku.org/type/Hash and 
https://docs.raku.org/routine/:=




Now we got an error.

Someone may explain me why I got this error??

Thanks in advance




--
Aureliano Guedes
skype: aureliano.guedes
contato:  (11) 94292-6110
whatsapp +5511942926110




native union structure

2021-06-01 Thread Marcel Timmerman

Hi,

(I reposted this because I did not saw it appear on the mailing list and 
added some new info)


I wanted to make a union to map some type to a byte array and back again 
so I started off like so;


# example class I want to map to a byte array
class N-GtkTargetEntry is repr('CStruct') is export {
  has Str $.target;
  has guint $.flags;
  has guint $.info;

  submethod BUILD ( Str :$target, Int :$!flags, Int :$!info ) {
    $!target := $target;
  }
}


# mapper class/union
class TargetEntryBytes is repr('CUnion') {
  HAS N-GtkTargetEntry $.target-entry;
  HAS CArray[uint8] $.target-bytes;

  multi submethod BUILD ( N-GtkTargetEntry :$target-entry! ) {
    $!target-entry := $target-entry;
  }

  multi submethod BUILD ( CArray[uint8] :$target-bytes! ) {
    $!target-bytes := $target-bytes;
  }
}


The first build method of class N-TargetEntryBytes is doing well and 
when setting the $!target-entry I can retrieve the bytes from 
$!target-bytes.


Now, the second build method gives problems. I get nonsense values for 
the fields of $!target-entry when I set the $!target-bytes.


Then, the next attempt for the BUILD did not improve matters

  multi submethod BUILD ( CArray[uint8] :$target-bytes! ) {
    $!target-bytes := CArray[uint8].new;
    my Int $array-size = nativesizeof(N-GtkTargetEntry);
    for ^$array-size -> $i {
  $!target-bytes[$i] = $target-bytes[$i];
    }
  }

What I think is happening here is that only an address is stored, 
pointing to an array elsewhere which does not map to the other union 
member. In this situation, the creation of the array does not take the 
'HAS' (uppercased!) attribute declaration into account.



I get a better result when the line '$!target-bytes := 
CArray[uint8].new;' is replaced by  '$!target-entry := 
N-GtkTargetEntry.new( :target(''), :flags(0), :info(0));' making space 
by setting a dummy $!target-entry first and then overwrite the data by 
writing in $!target-bytes.


Still not correct, the target value in the N-GtkTargetEntry keeps the 
string value I set, i.e. the empty string ''. Flags and info are now ok.


Final changes shown below give the proper outcome, i.e. the target 
string, flags and info  in the N-GtkTargetEntryclassare now set to the 
correct values! (Change is that the init of N-GtkTargetEntry in the 2nd 
BUILD is called without the :target argument)



class N-GtkTargetEntry is repr('CStruct') is export {
  has Str $.target;
  has guint $.flags;
  has guint $.info;

  submethod BUILD ( Str :$target?, Int :$!flags = 0, Int :$!info = 0 ) {
    $!target := $target if $target.defined;
  }
}

class TargetEntryBytes is repr('CUnion') {
  HAS N-GtkTargetEntry $.target-entry;
  HAS CArray[uint8] $.target-bytes;

  multi submethod BUILD ( N-GtkTargetEntry :$target-entry! ) {
    $!target-entry := $target-entry;
  }

  multi submethod BUILD ( CArray[uint8] :$target-bytes! ) {
    # need to make dummy to create proper space
    $!target-entry := N-GtkTargetEntry.new;

    my Int $array-size = nativesizeof(N-GtkTargetEntry);

    for ^$array-size -> $i {
  $!target-bytes[$i] = $target-bytes[$i];
    }
  }
}



The question: is there an explanation for this behavior because I do not 
understand it completely why it should be written like this ? It feels 
that there are some quirks where you need to program around it and 
afraid that it might change later without warning?



Regards,
Marcel



Re: My OOP keeper

2021-02-14 Thread Marcel Timmerman

Hi Ralph,

You are very right!

Since I am working with the language binding of Raku to the Gnome 
libraries like Gtk I have seen that their code is neatly OO while 
written in C which does not know about classes and the like.


Regards,
Marcel


Re: My OOP keeper

2021-02-14 Thread Marcel Timmerman

Hi Todd,

I would like to spend one line or two on your OOP keeper. One important 
aspect of object oriented programming is dat you encapsulate your 
knowledge into an object. That is, structures and other variables should 
be kept invisible to the user of your object. That way, you are able to 
change your algorithms in your object without hurting people in the future.


This is what I see all the time in your keeper;

has SomeType $.some-variable;

The variable is, as you know, readable from outside your object, but it 
also creates a dependency on that variable by the users of your class. 
Once used, you cannot change it without causing pain somewhere else.


So what you must do normally;

has SomeType $!some-variable;

and the other sparingly, like you've shown using native structures!

Now that I am at it, don't use 'self.some-variable' from within your 
object. It is faster and also better to read to just write 
'$!some-variable' whether it is made readable or even writable.


Marcel


Re: Continuous testing

2020-12-29 Thread Marcel Timmerman

Maybe not the proper thread, ... but may be nice to know or even helpful ...

Using native integers I did not know which integer to choose when a C 
type int was specified in a function signature. It is known that, 
depending on processor or compiler, an int could have 16 or 32 bits size 
and a long could have 32 or 64.


So what I've done, to be free of that, is making a mapping of types 
which is generated at install time. Before the mapping is generated, the 
program runs a C program which displays the INT_MAX and INT_MIN etc. 
From that, I can see how many bits are needed and can then make a 
proper mapping to e.g int16, int32 or int64.


In the attachments there are some scripts and programs used in 
gnome-native and generates type mappings from glib types to Raku native 
types. The Build.pm6 module generates this module and is already in use 
in some of the Gnome::*::* modules. A sample GlibToRakuTypes.pm6 is 
included.


Regards,
Marcel

/*
 compile: gcc -o c-type-size c-type-size.c

 See also:
   https://www.tutorialspoint.com/c_standard_library/limits_h.htm
   https://www.tutorialspoint.com/cprogramming/c_data_types.htm
   https://en.wikibooks.org/wiki/C_Programming/limits.h
   https://www.gnu.org/software/libc/manual/html_node/Range-of-Type.html
*/

#include 
#include 
#include 
#include 

int main(int argc, char** argv) {

  printf("CHAR_BIT : %d\n", CHAR_BIT);
  printf("CHAR_MAX : %d\n", CHAR_MAX);
  printf("CHAR_MIN : %d\n", CHAR_MIN);

  printf("INT_MAX  : %d\n", INT_MAX);
  printf("INT_MIN  : %d\n", INT_MIN);
  printf("UINT_MAX : %u\n", (unsigned int) UINT_MAX);

  printf("LONG_MAX : %ld\n", (long) LONG_MAX);
  printf("LONG_MIN : %ld\n", (long) LONG_MIN);
  printf("ULONG_MAX: %lu\n", (unsigned long) ULONG_MAX);

  printf("SCHAR_MAX: %d\n", SCHAR_MAX);
  printf("SCHAR_MIN: %d\n", SCHAR_MIN);
  printf("SHRT_MAX : %d\n", SHRT_MAX);
  printf("SHRT_MIN : %d\n", SHRT_MIN);
  printf("UCHAR_MAX: %d\n", UCHAR_MAX);
  printf("USHRT_MAX: %d\n", (unsigned short) USHRT_MAX);

  return 0;
}
use v6;

my Bool $run-ok;
my Hash $c-types = %();

try {
  my Proc $proc;

  # make C program to get the limits of integers, float and doubles
  $proc = run 'gcc', '-o', 'xbin/c-type-size', 'xbin/c-type-size.c';

  # run this C program to read the limits
  $proc = run 'xbin/c-type-size', :out;

  for $proc.out.lines -> $line {
my ( $limit-name, $limit) = $$line.split(/ \s* ':' \s* /);
  #  note "$limit-name, $limit";
next if $limit-name ~~ m/ MIN | SCHAR /;

$limit-name ~~ s/SHRT/SHORT/;
$limit-name .= lc;
$limit-name = 'g' ~ $limit-name;

$limit .= Int;

given $limit-name {
  #when 'CHAR_BIT' {
  #  note "$limit-name, $limit, int$limit.base(16)";
  #}

  when / 'u' .*? '_max' $/ {
$limit-name ~~ s/ '_max' //;
$c-types{$limit-name} = 'uint' ~ $limit.base(16).chars * 4;
  #  note sprintf( "%11s uint%d",
  #$limit-name, $limit.base(16).chars * 4
  #  );
  }

  when / '_max' $/ {
$limit-name ~~ s/ '_max' //;
$c-types{$limit-name} = 'int' ~ $limit.base(16).chars * 4;
  #  note sprintf( "%11s int%d",
  #$limit-name, $limit.base(16).chars * 4
  #  );
  }
  #`{{
  when 'INT_MAX' {
note "0x$limit.base(16)", 'int' ~ ($limit.base(16).chars * 4).Str;
  }

  when 'INT_MIN' {
note "0x$limit.base(16)", 'int' ~ ($limit.base(16).chars * 4).Str;
  }

  when 'UINT_MAX' {
note "0x$limit.base(16), ", 'int' ~ ($limit.base(16).chars * 4).Str;
  }

  when 'LONG_MAX' {
note "0x$limit.base(16)", 'int' ~ ($limit.base(16).chars * 4).Str;
  }

  when 'LONG_MIN' {
note "0x$limit.base(16)", 'int' ~ ($limit.base(16).chars * 4).Str;
  }

  when 'ULONG_MAX' {
note "0x$limit.base(16), ", 'int' ~ ($limit.base(16).chars * 4).Str;
  }
  }}
}
  }

  $proc.out.close;
#  note $proc.exitcode;
  $run-ok = !$proc.exitcode;

  CATCH {
default {
  note "Failed to run C program, over to plan B, quesswork...";
  $run-ok = False;
}
  }
}

# when program fails or did not compile we need some guesswork. Raku has the
# idea that int is in64 on 64 bit machines which is not true in my case...
unless $run-ok {
#  note "\nBits: $*KERNEL.bits(), ", int64.Range;

  $c-types = 'int8';
  $c-types = 'int32';
  $c-types = $*KERNEL.bits() == 64 ?? 'int64' !! 'int32';
  $c-types = 'int16';
  $c-types = 'uint8';
  $c-types = 'uint32';
  $c-types = $*KERNEL.bits() == 64 ?? 'uint64' !! 'int32';
  $c-types = 'uint16';
}

# add other types which are fixed
$c-types = 'int8';
$c-types = 'int16';
$c-types = 'int32';
$c-types = 'int64';
$c-types = 'uint8';
$c-types = 'uint16';
$c-types = 'uint32';
$c-types = 'uint64';

$c-types = 'num32';
$c-types = 'num64';

$c-types = 'Str';
$c-types = 'Pointer[void]';

# and some types which are defined already
$c-types = $c-types;
$c-types = $c-types;
$c-types = $c-types;
$c-types = $c-types;
$c-types = $c-types;
$c-typ

Re: Continuous testing

2020-12-29 Thread Marcel Timmerman

On 12/23/20 7:45 PM, JJ Merelo wrote:
You can probably use AppVeyor. It's got good support for Windows, 
although you'll have to write for it specifically. This one seems to 
use it, for instance https://github.com/MARTIMM/gnome-native 



Hi Richard,

JJ is right about the Appveyor test of gnome-native but that one is only 
testing low level things not using anything of GTK. I did not do it for 
all packages yet but the closest working one is that of gnome-gdk3. You 
can find the results here; 
https://ci.appveyor.com/project/MARTIMM/gnome-gdk3/branch/master (with a 
lot of compiler warnings in the beginning though).


It is still failing for TRAVIS and I need to look at that still.

Below is the Appveyor script that I've used for gnome-gdk3 and might 
also work for gnome-gtk3 as well. I know that your package holds the 
necessary window libraries while mine is depending on the installation 
of the GTK libraries on Linuxes and using MSYS2 on windows in particular.



os: Visual Studio 2019
image:
  - Visual Studio 2019

platform: x64

branches:
  # whitelist
  only:
    - master

environment:
  raku_test_all: 1

install:
  - set 
PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%


  # install raku from git
  - cd C:\
  - git clone https://github.com/rakudo/rakudo.git
  - cd rakudo
  - perl Configure.pl --gen-moar --gen-nqp --backends=moar
  - gmake install
  - set 
PATH=C:\rakudo\install\bin;C:\rakudo\install\share\perl6\site\bin;%PATH%

  - cmd: dir C:\rakudo\install\bin

  # install zef from git
  - cd C:\
  - git clone https://github.com/ugexe/zef.git
  - cd zef
  - cmd: rakudo.exe -I. bin/zef install .
  - cmd: dir C:\rakudo\install\share\perl6\site\bin

  # set path to use MSYS2 tools like pacman
  - cd C:\
  - set PATH=C:\msys64\usr\bin;C:\msys64\usr\lib;%PATH%
  - bash -lc "pacman -S --noconfirm mingw-w64-x86_64-gtk3"
  - refreshenv

build: off

test_script:

  # set path to use Raku, Zef and GTK libraries
  - set 
PATH=C:\rakudo\install\bin;C:\rakudo\install\share\perl6\site\bin;C:\msys64\mingw64\bin;%PATH%


  - cd %APPVEYOR_BUILD_FOLDER%
  - cmd: zef --/test --deps-only install .
  - cmd: zef --verbose install .


Marcel



El mié, 23 dic 2020 a las 16:35, Richard Hainsworth 
(mailto:rnhainswo...@gmail.com>>) escribió:


Hi to everyone.

Hope you all have a happy holiday time at the end of the year -
different countries different celebrations, but good will to all.

Hope 2021 is properous for you all too.

About continuous testing. I have recently taken on the maintenance of
GTK::Simple.

The Travis-CI setup was constructed a while ago and tested both
OSX and
Linux, but not Windows.

It was failing for OSX and for one of the Linux environments.

So I have changed it to the minimal docker image provided by JJ -
kudos
that man!!!

However, that required a removal of OSX - bad.

In addition, GTK::Simple is difficult to install on Windows, so I'll
need help there, but I would like to know how test a module for
Windows
anyway.

For clarity, I last used a Mac in the naughties, and stopped using
Windows as soon as I could get what I needed from Linux. So
basically, I
have minimal recent knowledge of these environments.

I have two questions:

a) Could any one provide me with a CI scheme that would cover Linux /
OSX / Windows?

Not necessarily on the same server environment.

There is an issue in GTK::Simple to the effect that it would be
better
to use github Actions instead of Travis-CI et al. A comment on this
theme would help.

b) Is there a reasonable link to a blog/tutorial on CI ?

I think that there should be some basic information on CI in the Raku
documentation on Modules. If anyone answers q1 for me, then I'll
write
up the scheme I adopt for the Modules documentation together with
a link
to better information.

When I have asked this question before, I haven't had much response.
Either I have had answers that assume everyone know about CI, or most
often I get a response that the answerer just copies/pastes
configurations from other modules.

Whilst CI is not a part of Raku, a basic CI scheme that could be
adopted
by all Module writers would enhance the robustness of the Raku module
community.



--
JJ




Re: Pointer and OpaquePointer

2020-12-06 Thread Marcel Timmerman

Hi,
I'm afraid that I've done something wrong somewhere else... Changed it 
all back to OpaquePointer and kept the same problem. So I must look into 
it deeper and just use the Pointer instead.


Regards,
Marcel


Pointer and OpaquePointer

2020-12-05 Thread Marcel Timmerman

Hi,

I would like to know the difference between a Pointer and an 
OpaquePointer. I have found an entry in the FAQ where it stated that 
OpaquePointer is deprecated.


My problem here is that the use of Pointer at several places gives 
irregular errors, hangups or mysterious crashes without stack dumps. 
There was an occasional error from the C library I use which helped me 
out to look at the proper spot which was at changes I recently made from 
OpaquePointer into Pointer.


I would like to know the difference because then I could make proper 
changes using the Pointer type and leave the OpaquePointer to history.


Thanks in advance,
Marcel


Re: Extended identifiers in named attributes

2020-08-28 Thread Marcel Timmerman

Hi Ralph,
Thanks for your answer.

The name 'attributes' was wrong, I meant 'arguments'. Sorry for that. I 
was working on XML files and mixed up some terms.

I don't think you're supposed to be able to have extended identifiers
as named parameter/argument identifiers. They are meant for a few
specific scenarios where there's special value in having adverbs aka
pairs embedded in identifiers:

* Alternations in grammars. Typically of form `foo:sym`.

* Appending :api<>, :auth<>, :ver<> to package identifiers.

They *may* work in a couple of other scenarios but in general,
don't do that.

By the way, "attributes" has a specific meaning in Raku, namely the
fields of object instances.

Regards,
Marcel


--
love, raiph


On Wed, Aug 26, 2020 at 1:31 PM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hi everyone,

I was experimenting with extended identifiers and found that it is
not possible to use it in named attributes. E.g.

> sub a (:$x:y) { say $x:y; }
===SORRY!=== Error while compiling:
Unsupported use of y///.  In Raku please use: tr///.
--> sub a (:$x:y⏏) { say $x:y; }


> sub a (:$abc:def) { say $abc:def; }
===SORRY!=== Error while compiling:
Invalid typename 'def' in parameter declaration.
--> sub a (:$abc:def⏏) { say $abc:def; }

Is there a trick of some sort to get this done? At the moment I
can only use a slurpy hash and check for its keys. This is good
enough for me but out of curiosity I ask. If not possible, an
extra note in the documentation on named arguments would be necessary.

regards,
Marcel






Re: Extended identifiers in named attributes

2020-08-26 Thread Marcel Timmerman

On 2020-08-26 17:48, Tom Browder wrote:
On Wed, Aug 26, 2020 at 07:31 Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


I was experimenting with extended identifiers and found that it is

not possible to use it in named attributes. E.g.

> sub a (:$x:y) { say $x:y; }

Are you sure that is supposed to work without some kind of () or <> 
like a module identifier? But a doc note would be helpful.


Best regards,

-Tom

Hi Tom,

One example from the doc is: WOW:That'sAwesome, so yes, I believe that 
should be possible. Also I've already used this in Xml::Actions where 
function names can be named like abc:def:start(). A small REPL test 
shows also that a simple assignment works on these type of variables;



my $abc:def = 10;

10

say $abc:def;

10

Regards,
Marcel


Extended identifiers in named attributes

2020-08-26 Thread Marcel Timmerman

Hi everyone,

I was experimenting with extended identifiers and found that it is not 
possible to use it in named attributes. E.g.



sub a (:$x:y) { say $x:y; }

===SORRY!=== Error while compiling:
Unsupported use of y///.  In Raku please use: tr///.
--> sub a (:$x:y⏏) { say $x:y; }



sub a (:$abc:def) { say $abc:def; }

===SORRY!=== Error while compiling:
Invalid typename 'def' in parameter declaration.
--> sub a (:$abc:def⏏) { say $abc:def; }

Is there a trick of some sort to get this done? At the moment I can only 
use a slurpy hash and check for its keys. This is good enough for me but 
out of curiosity I ask. If not possible, an extra note in the 
documentation on named arguments would be necessary.


regards,
Marcel




Re: delimiters with more than one character? ...

2020-07-16 Thread Marcel Timmerman

On 2020-07-16 15:17, Parrot Raiser wrote:

Perhaps with a grammar?

On 7/16/20, Tom Browder  wrote:

An opportunity for Raku golfers to show off Raku on the Debian users list.

Best regards,

-Tom

-- Forwarded message -
From: Albretch Mueller 
Date: Tue, Jul 14, 2020 at 07:52
Subject: delimiters with more than one character? ...
To: Debian Users ML 


  I have a string delimited by two characters: "\|"

  _S=" 34 + 45 \| abc \| 1 2 3 \| c\|123abc "

  which then I need to turn into a array looking like:

   _S_AR=(
" 34 + 45"
" abc"
" 1 2 3"
" c"
"123abc"
)

   I can't make awk or tr work in the way I need and all examples I
have found use only one character.

   Is it possible to do such things in bash?

   lbrtchx



A single quoted string:
' 34 + 45 \| abc \| 1 2 3 \| c\|123abc '.split('\|').join(', ');
returns: 34 + 45 ,  abc ,  1 2 3 ,  c, 123abc

A double quoted string interprets '\' so;
" 34 + 45 \| abc \| 1 2 3 \| c\|123abc ".split('|').join(', ')
returns: 34 + 45 ,  abc ,  1 2 3 ,  c, 123abc

spaces are still left in. The join is used to show the strings in the 
array a bit better.


Regards,
Marcel


Re: impact of compiling pod doc

2020-07-14 Thread Marcel Timmerman

Thank you for answer JJ.

It is quite a work to split such a large file up so I thought I'd better 
ask before I dive in head first. Later I might think it over. I have 
this documentation on the github pages too so I could separate the pod 
doc and keep them somewhere else where they won't get processed and 
installed.


Thanks again,
Marcel

It's going to be pretty much the same. If it's installed, it's going 
to be precompiled anyway. The overhead added by reading the file might 
even make it slower.
Of course, you can always give it a try and measure. Measuring might 
always surprise you :-)


El mar., 14 jul. 2020 a las 14:20, Marcel Timmerman (<mailto:mt1...@gmail.com>>) escribió:


Hi,

I was wondering if pod documentation has a large impact on compiling
modules. I assume on small files it would be ignorable but I have
some
modules which have grown big, one has 7153 lines of which the biggest
part is pod doc. Would it be useful to split such a file in two.
one for
code and the other for doc to improve the install time?

Regards,
Marcel



--
JJ




impact of compiling pod doc

2020-07-14 Thread Marcel Timmerman

Hi,

I was wondering if pod documentation has a large impact on compiling 
modules. I assume on small files it would be ignorable but I have some 
modules which have grown big, one has 7153 lines of which the biggest 
part is pod doc. Would it be useful to split such a file in two. one for 
code and the other for doc to improve the install time?


Regards,
Marcel


Re: cannot create an instance of subset type

2020-07-11 Thread Marcel Timmerman

On 2020-07-10 23:37, Brad Gilbert wrote:

Subset types are not object types.

A subset is basically a bit of checking code and base type associated 
with a new type name.


In something like:

    my ABC $a .= new;

That is exactly the same as:

    my ABC $a = ABC.new;

Well there is no functional `.new` method on any subset types, so 
`DEF.new()` isn't going to do anything.


    DEF.new # ERROR

---

The worst part of your code is that you are using a `subset` without a 
`where` clause. Which is almost completely pointless.


I honestly think that there is an argument to be made that it 
shouldn't even be possible to write a `subset` without a `where` clause.


It isn't like other languages where you can create something like a 
lightweight clone or lightweight subclass of a type.

It also isn't an alias.

It's whole purpose is to attach a `where` clause as an extra check to 
type based things.




If you want an alias, use an alias

    my constant DEF = ABC;

    my constant DEF = ABC:D;

If you want a lightweight subclass, create a lightweight subclass.

    my class DEF is ABC {}

If you want an extra check, then and only then does it make sense to 
use a `subset`.


    my subset GHI of Int where -10 ≤ $_ ≤ 10;

---

A `subset` without a `where` clause only makes certain 
language features become unavailable.

Unless that is exactly what you want to accomplish, use something else.


Thanks very much Brad, for your answer. I understand completely. It was 
needed to mimic a C typedef which created a new type name from another. 
The example 'my constant DEF = ABC;' above would just do fine. I didn't 
thought about 'my class DEF is ABC {}' though, which also would work but 
creates more code I presume.


What I understand also now is that a subset is used on places where 
variables are assigned or bound like in argument lists and never created 
anew. Then, like you said, the where clause is always useful, if not 
obligatory, otherwise one could use the original type.


Regards,
Marcel


On Fri, Jul 10, 2020 at 3:18 PM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hi,

Using the next code I get an error on the instantiation of $d2;

---
use v6;

class ABC {
   method s ( Int $i ) { say $i + 10; }
}

subset DEF of ABC;

my ABC $a .= new;
$a.s(10);   # 20

my DEF $d1 = $a;
$d1.s(11);  # 21

my DEF $d2 .= new;
$d2.s(12);
---

Error is

You cannot create an instance of this type (DEF)
   in block  at xt/subset-test.pl6 line 15

Why is this?

Regards,
Marcel





cannot create an instance of subset type

2020-07-10 Thread Marcel Timmerman

Hi,

Using the next code I get an error on the instantiation of $d2;

---
use v6;

class ABC {
  method s ( Int $i ) { say $i + 10; }
}

subset DEF of ABC;

my ABC $a .= new;
$a.s(10);   # 20

my DEF $d1 = $a;
$d1.s(11);  # 21

my DEF $d2 .= new;
$d2.s(12);
---

Error is

You cannot create an instance of this type (DEF)
  in block  at xt/subset-test.pl6 line 15

Why is this?

Regards,
Marcel


Re: an error I don't understand

2020-07-01 Thread Marcel Timmerman

Solved!

It had something to do with having an installed version and testing a 
program using a partly changed local version (renames of files too) and 
partly the installed version. This caused the same type from several 
sources and thereby making them differ. Removing the installed versions 
cleared every error.


That leaves us with the error message not completely comprehensible by 
people like me. Raku does see a difference but doesn't say which.


Anyways, thanks for answering
Marcel


Re: an error I don't understand

2020-06-27 Thread Marcel Timmerman

Hi Brad,


I don't know why you are getting an error.

But I think that this is one case where you should be writing `BUILD` 
instead of `TWEAK`.

Note though that you can only have one `BUILD` or `TWEAK` per class.
A quick test showed to me that it doesn't matter if I use BUILD or 
TWEAK. Besides this, I tried this construct before without the TWEAK or 
BUILD submethods and the assignment generated the same errors.


To answer your question below I just want to have an assignment to 
another typed variable which works for all variables but not the CStruct 
variable. Like below;


my cairo_path_data_point_t $p1 = $another-path-data-point;

I must also mention that it becomes awkward when such a variable is 
provided as an argument to some method. Binding will generate also such 
message.


In the mean time I made a small program which didn't generate errors, 
see below

---
use v6;
use NativeCall;

class cairo_path_data_point_t is repr('CStruct') is export {
  has num64 $.x;
  has num64 $.y;
}

my cairo_path_data_point_t $d1 .= new( :x(1e0), :y(2e0));
my cairo_path_data_point_t $d2 = $d1;

note "d2: ", $d2.perl;            # d2: cairo_path_data_point_t.new(x => 
1e0, y => 2e0)

---

and this is what I want I now need a Crystal Ball to find me the 
answer of the problems I ran into :-\


Well, at least the error is weird to warn me that I cannot assign a 
variable to another of the same type.


Regards,
Marcel


---

Or maybe you want a multi method `new` instead?

    multi method new ( :$native-object! ) {
        samewith( x => $native-object.x, y => $native-object.y )
    }

Assuming that `x` and `y` are actually public attributes you could 
pull them out of the object in the signature.


    multi method new ( :$native-object! (:$x, :$y) ) {
        samewith( :$x, :$y )
    }

If you need to throw out other public attributes, add `*%`

    multi method new ( :$native-object! (:$x, :$y, *%) ) {
        samewith( :$x, :$y )
    }

---

Honestly I do not understand why you are passing in an already 
constructed object, and I don't know anything about it either.


If you gave us answers for those two questions, we may be able to help 
you better.



On Sat, Jun 27, 2020 at 10:56 AM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hi,

I am getting an error and don't know why it happens, it might even
be a
bug. It is about an assignment to a CStruct variable.

The structure is defined like;

class cairo_path_data_point_t is repr('CStruct') is export {
   has num64 $.x;
   has num64 $.y;

   submethod TWEAK ( :$native-object ) {
 $!x = $native-object.x;
 $!y = $native-object.y;
   }
}


The error is generated when typed variables are used (below, $x is
also
a cairo_path_data_point_t);

my cairo_path_data_point_t $p1 = $x;

or

my cairo_path_data_point_t $p1 =
cairo_path_data_point_t.new(:native-object($x));

but not with

my cairo_path_data_point_t $p1 .= new(:native-object($x));

or

my $p1 = $x;

After which all fields in the structure are happely accessable
using $p1!


The error is

Type check failed in assignment to $p1; expected
cairo_path_data_point_t
but got cairo_path_data_point_t.new(x => 0e0, y => 0e0)


Raku version: 2020.06-7-gf1960baa9 built on MoarVM version
2020.06-6-gbf6af07de
implementing Raku 6.d.

The content of the structure does not matter, I've seen it with other
structures too.

Regards,
Marcel





an error I don't understand

2020-06-27 Thread Marcel Timmerman

Hi,

I am getting an error and don't know why it happens, it might even be a 
bug. It is about an assignment to a CStruct variable.


The structure is defined like;

class cairo_path_data_point_t is repr('CStruct') is export {
  has num64 $.x;
  has num64 $.y;

  submethod TWEAK ( :$native-object ) {
    $!x = $native-object.x;
    $!y = $native-object.y;
  }
}


The error is generated when typed variables are used (below, $x is also 
a cairo_path_data_point_t);


my cairo_path_data_point_t $p1 = $x;

or

my cairo_path_data_point_t $p1 = 
cairo_path_data_point_t.new(:native-object($x));


but not with

my cairo_path_data_point_t $p1 .= new(:native-object($x));

or

my $p1 = $x;

After which all fields in the structure are happely accessable using $p1!


The error is

Type check failed in assignment to $p1; expected cairo_path_data_point_t 
but got cairo_path_data_point_t.new(x => 0e0, y => 0e0)



Raku version: 2020.06-7-gf1960baa9 built on MoarVM version 
2020.06-6-gbf6af07de

implementing Raku 6.d.

The content of the structure does not matter, I've seen it with other 
structures too.


Regards,
Marcel


Re: endian

2020-01-24 Thread Marcel Timmerman

On 1/23/20 6:28 PM, ToddAndMargo via perl6-users wrote:
On Thu, Jan 23, 2020 at 11:51 AM ToddAndMargo via perl6-users 
mailto:perl6-us...@perl.org>> wrote:


    Hi All,

    This is just a trivia question.

    Does anyone know if the actual data stored in
    Raku variables is little endian or big endian?

    -T


On 2020-01-23 09:07, Paul Procacci wrote:

endianess is dictate by the cpu.
If I store the value 4 into some memory address, the storage of and 
retrieval thereof is controlled by the cpu.




Then I presume Raku rug on a Intel processor would
be little endian.  So when I enter 0xFF44 it is
really being stored as 44, FF in memory.  Interesting.


Most of the time you don't really need to know unless you move your data 
from one machine to another in binary form. In that case you need a test 
before interpreting the data.


Marcel


Re: definition confusion of + and +^

2020-01-19 Thread Marcel Timmerman

On 1/19/20 2:47 AM, ToddAndMargo via perl6-users wrote:

Hi All,

Thank you all for the wonderful help on this.

What I am still confused about is how to
read these silly definition lines:

   multi sub infix:<+>($a, $b --> Numeric:D)
   multi sub infix:<+^>($a, $b --> Int:D)

How exactly does the above tell me to do this?

  $c = $a +  $b
  $c = $a +^ $b

I figured I'd start with addition and work my
way up.


It is what Elizabeth already said and a bit of latin would help.

prefix:+foo
'pre' means something like 'before'. What is before then. It is about
operators. So an operator goes before an argument. '+foo' here could 
then be +$a.
Other prefix examples are ?$a, !$a, -$a, .

postfix:   foo++
'post' means something like 'after'. The operator goes after the 
argument. Examples
are $a++, $b--.
 
infix: foo + bar

This means that the operator is in between arguments. Like $a + $b, $a 
** 2.

circumfix: [foo]
Means the operator goes around the argument. Like a list ( $a, $b, 3, 4 
)

postcircumfix: foo[bar]
The operator here is placed around an argument which is placed after 
another.
Like @a[$b], (^10)[3], %h{$k}

Marcel


Many thanks,
-T


Re: Bug to report: cardinal called an integer

2020-01-12 Thread Marcel Timmerman

On 1/9/20 7:10 PM, ToddAndMargo via perl6-users wrote:

'my uint32 $c; $c = "ABC";'
The error shows that you cannot assign a string to an int (*This type 
cannot unbox to a native integer: P6opaque, Str*)


You can do the following to get it right;

'p6  -e 'my uint32 $c; $c = 0xABC;''




Re: about 'use v6.d'

2019-12-13 Thread Marcel Timmerman

On 12/13/19 3:32 PM, Vadim Belman wrote:

Hello Marcel,

You make certain assumptions, then you make them something like facts and 
proclaim things based on these. Please, don't!

Sorry that I did, apologies for that.


Re: implicit type change

2019-12-08 Thread Marcel Timmerman

Hi Elizabeth,

Shall I file a bug report then?


I hoped that:

   $ 6 'use NativeCall; dd my CArray[uint8] $ba .= new( 255, 254, 3, 4); dd 
$ba[0..*-1]'
   CArray[uint8] $ba = NativeCall::Types::CArray[uint8].new
   (-1, -2, 3, 4).Seq

would be a solution (usint "uint8" rather than "byte"), but alas, no, so this 
feels like a bug


On 8 Dec 2019, at 20:01, Marcel Timmerman  wrote:

Hello,

I have a nasty problem using native call interface. I get an array of bytes 
from a call representing a pixel buffer. I am storing it in a CArray[byte]. 
Golfing it down it comes to the following (REPL)



use NativeCall
my CArray[byte] $ba .= new( 255, 254, 3, 4);

NativeCall::Types::CArray[byte].new

$ba[0].WHAT

(Int)

$ba[0..*-1]

(-1 -2 3 4)


This means (for me) that there is an implicit type conversion from unsigned to 
signed integer and it is not possible to use positive numbers only, afterwards.

Regards,
Marcel


Re: implicit type change

2019-12-08 Thread Marcel Timmerman

On 12/8/19 8:19 PM, Fernando Santagata wrote:
It looks like a bug: the docs 
(https://docs.raku.org/language/nativetypes) specify that 'byte' and 
'uint8' are the same and correspond to uint8_t in C.

Substituting 'uint8' to 'byte' in your code returns the same result.

Out of curiosity, if it is something meant for the public, what native 
call interface are you working on?

Hi Fernando,

I'm working on the Gnome GTK+ interface. I started this as a learning 
task for the native call interface but it is grown into a huge project. 
The packages are Gnome::N, Gnome::Glib, Gnome::GObject, Gnome::Gdk3, 
Gnome::Gtk3, Gnome::Gtk3::Glade and more to come.




On Sun, Dec 8, 2019 at 8:08 PM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hello,

I have a nasty problem using native call interface. I get an array of
bytes from a call representing a pixel buffer. I am storing it in a
CArray[byte]. Golfing it down it comes to the following (REPL)


 > use NativeCall
 > my CArray[byte] $ba .= new( 255, 254, 3, 4);
NativeCall::Types::CArray[byte].new
 > $ba[0].WHAT
(Int)
 > $ba[0..*-1]
(-1 -2 3 4)


This means (for me) that there is an implicit type conversion from
unsigned to signed integer and it is not possible to use positive
numbers only, afterwards.

Regards,
Marcel



--
Fernando Santagata




implicit type change

2019-12-08 Thread Marcel Timmerman

Hello,

I have a nasty problem using native call interface. I get an array of 
bytes from a call representing a pixel buffer. I am storing it in a 
CArray[byte]. Golfing it down it comes to the following (REPL)



> use NativeCall
> my CArray[byte] $ba .= new( 255, 254, 3, 4);
NativeCall::Types::CArray[byte].new
> $ba[0].WHAT
(Int)
> $ba[0..*-1]
(-1 -2 3 4)


This means (for me) that there is an implicit type conversion from 
unsigned to signed integer and it is not possible to use positive 
numbers only, afterwards.


Regards,
Marcel


Re: processing a file in chunks

2019-10-23 Thread Marcel Timmerman

Thank you very much Brad, This I didn't know
Regards
Marcel


CatHandle is the mechanism behind $*ARGFILES.

If you want to read several files as it they were one, you can use 
IO::CatHandle.


    my $combined-file = IO::CatHandle.new( 'example_000.txt', *.succ 
... 'example_010.txt' );


Basically it works similar to the `cat` command-line utility. (Hence 
its name)


The reason it is read-only, is because it is difficult to figure out 
which file you actually want to write to.


Imagine you read the first file, and then wrote something.
Should it write to the end of the first file, or the beginning of the 
second file?


On Tue, Oct 22, 2019 at 2:08 PM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


On 10/22/19 3:03 PM, Parrot Raiser wrote:
> CatHandle? Is that an alias for "tail"?  :-)*
hehe, that's a nice word change... Well, I've seen it here at
https://docs.perl6.org/routine/readchars

But there's also IO::Handle  What I've understood is that the
CatHandle does the same as a readonly IO::Handle can. Writing will
throw
exceptions. So in the end it looks like the Unix tail program.

Marcel
>
> On 10/22/19, Marcel Timmerman mailto:mt1...@gmail.com>> wrote:
>> On 10/22/19 1:05 PM, Marcel Timmerman wrote:
>>> On 10/20/19 11:38 PM, Joseph Brenner wrote:
>>>> I was just thinking about the case of processing a large file in
>>>> chunks of an arbitrary size (where "lines" or "words" don't
really
>>>> work).   I can think of a few approaches that would seem kind-of
>>>> rakuish, but don't seem to be built-in anywhere... something
like a
>>>> variant of "slurp" with an argument to specify how much you
want to
>>>> slurp at a time, that'll move on to the next chunk the next
time it's
>>>> invoked...
>>>>
>>>> Is there anything like that kicking around that I've missed?
>>> as a side note, there is also a .IO.CHandle.readchars($size), with
>>> $size a default of 64 kb.
>>>
>>> Regards,
>>> Marcel
>> I meant  .IO.CatHandle.readchars($size)
>> sorry
>> M
>>





Re: processing a file in chunks

2019-10-22 Thread Marcel Timmerman

On 10/22/19 3:03 PM, Parrot Raiser wrote:

CatHandle? Is that an alias for "tail"?  :-)*
hehe, that's a nice word change... Well, I've seen it here at 
https://docs.perl6.org/routine/readchars


But there's also IO::Handle  What I've understood is that the 
CatHandle does the same as a readonly IO::Handle can. Writing will throw 
exceptions. So in the end it looks like the Unix tail program.


Marcel


On 10/22/19, Marcel Timmerman  wrote:

On 10/22/19 1:05 PM, Marcel Timmerman wrote:

On 10/20/19 11:38 PM, Joseph Brenner wrote:

I was just thinking about the case of processing a large file in
chunks of an arbitrary size (where "lines" or "words" don't really
work).   I can think of a few approaches that would seem kind-of
rakuish, but don't seem to be built-in anywhere... something like a
variant of "slurp" with an argument to specify how much you want to
slurp at a time, that'll move on to the next chunk the next time it's
invoked...

Is there anything like that kicking around that I've missed?

as a side note, there is also a .IO.CHandle.readchars($size), with
$size a default of 64 kb.

Regards,
Marcel

I meant  .IO.CatHandle.readchars($size)
sorry
M



Re: processing a file in chunks

2019-10-22 Thread Marcel Timmerman

On 10/22/19 1:05 PM, Marcel Timmerman wrote:

On 10/20/19 11:38 PM, Joseph Brenner wrote:

I was just thinking about the case of processing a large file in
chunks of an arbitrary size (where "lines" or "words" don't really
work).   I can think of a few approaches that would seem kind-of
rakuish, but don't seem to be built-in anywhere... something like a
variant of "slurp" with an argument to specify how much you want to
slurp at a time, that'll move on to the next chunk the next time it's
invoked...

Is there anything like that kicking around that I've missed?
as a side note, there is also a .IO.CHandle.readchars($size), with 
$size a default of 64 kb.


Regards,
Marcel


I meant  .IO.CatHandle.readchars($size)
sorry
M


Re: processing a file in chunks

2019-10-22 Thread Marcel Timmerman

On 10/20/19 11:38 PM, Joseph Brenner wrote:

I was just thinking about the case of processing a large file in
chunks of an arbitrary size (where "lines" or "words" don't really
work).   I can think of a few approaches that would seem kind-of
rakuish, but don't seem to be built-in anywhere... something like a
variant of "slurp" with an argument to specify how much you want to
slurp at a time, that'll move on to the next chunk the next time it's
invoked...

Is there anything like that kicking around that I've missed?
as a side note, there is also a .IO.CHandle.readchars($size), with $size 
a default of 64 kb.


Regards,
Marcel


Re: order of execution

2019-10-22 Thread Marcel Timmerman

Thanks everyone,

I wonder, should I file an issue at rakudo's?

Marcel


Programs are compiled in memory, it just isn't written out to disk.

On Mon, Oct 21, 2019 at 3:33 AM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


@yary

Thanks for your answer. I've done it too and saw the same kind of
result. But then I thought I've read it somewhere that programs
are not compiled, only modules. So I must write a module to check it.

But if anyone knows, it would be faster ;-)

Regards,

marcel

On 20-10-2019 22:59, yary wrote:

Seems like we can answer "Is it also true when compiling?" by
putting the REPL code into a file!

$ cat order-execution.raku
class Y { method  y (Int $y) {note $y}}
my Y $y .= new;

sub b (Int $i --> Int) { note "about to increment i above $i"; $i
+ 10 }

say b(10);

say $y.?y(b(11));

say $y.?undef(b(12));

$ perl6 order-execution.raku
about to increment i above 10
20
about to increment i above 11
21
True
about to increment i above 12
Nil

$ perl6 --version
/This is Rakudo Star version 2019.03.1 built on MoarVM version
2019.03 //implementing Perl 6.d./

Yes Rakudo is executing the args for something that it doesn't
end up calling. Seems overly-eager for a language that is
properly lazy by design. I'd be interested in seeing
documentation for this order-of-operations if it exists.

By the way I had to look up .? -
https://docs.perl6.org/language/operators#index-entry-methodop_.%3F


methodop |.?|
<https://docs.perl6.org/language/operators#___top>

Safe call operator. |$invocant.?method| calls method
|method| on |$invocant| if it has a method of such name.
Otherwise it returns Nil <https://docs.perl6.org/type/Nil>.

Technically, not a real operator; it's syntax special-cased
    in the compiler.


-y



On Sun, Oct 20, 2019 at 10:12 AM Marcel Timmerman
mailto:mt1...@gmail.com>> wrote:

Hello all,

I've a small question where I want to know what is processed
first in
the following line


$my-object.?"my-method"(some-complex-argument-calculation())


Will the sub 'some-complex-argument-calculation()' always be
run even
when 'my-method' is not available because the sub must be
executed
before the method is called.


In the REPL the sub is called despite a method is not
defined. Is it
also true when compiling?


 > class Y { method  y (Int $y) {note $y}}
(Y)

 > my Y $y .= new
Y.new

 >sub b (Int $i --> Int) { note "$i"; $i + 10 }
&b

 > b(10)
10
20

 > $y.?y(b(10))
10
20
True

 > $y.?undef(b(10))
10
Nil


Regards
Marcel





Re: order of execution

2019-10-21 Thread Marcel Timmerman

@yary

Thanks for your answer. I've done it too and saw the same kind of 
result. But then I thought I've read it somewhere that programs are not 
compiled, only modules. So I must write a module to check it.


But if anyone knows, it would be faster ;-)

Regards,

marcel

On 20-10-2019 22:59, yary wrote:
Seems like we can answer "Is it also true when compiling?" by putting 
the REPL code into a file!


$ cat order-execution.raku
class Y { method  y (Int $y) {note $y}}
my Y $y .= new;

sub b (Int $i --> Int) { note "about to increment i above $i"; $i + 10 }

say b(10);

say $y.?y(b(11));

say $y.?undef(b(12));

$ perl6 order-execution.raku
about to increment i above 10
20
about to increment i above 11
21
True
about to increment i above 12
Nil

$ perl6 --version
/This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03 
//implementing Perl 6.d./


Yes Rakudo is executing the args for something that it doesn't end up 
calling. Seems overly-eager for a language that is properly lazy by 
design. I'd be interested in seeing documentation for this 
order-of-operations if it exists.


By the way I had to look up .? - 
https://docs.perl6.org/language/operators#index-entry-methodop_.%3F



methodop |.?| <https://docs.perl6.org/language/operators#___top>

Safe call operator. |$invocant.?method| calls method |method| on
|$invocant| if it has a method of such name. Otherwise it returns
Nil <https://docs.perl6.org/type/Nil>.

Technically, not a real operator; it's syntax special-cased in the
compiler.


-y



On Sun, Oct 20, 2019 at 10:12 AM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hello all,

I've a small question where I want to know what is processed first in
the following line


$my-object.?"my-method"(some-complex-argument-calculation())


Will the sub 'some-complex-argument-calculation()' always be run even
when 'my-method' is not available because the sub must be executed
before the method is called.


In the REPL the sub is called despite a method is not defined. Is it
also true when compiling?


 > class Y { method  y (Int $y) {note $y}}
(Y)

 > my Y $y .= new
Y.new

 >sub b (Int $i --> Int) { note "$i"; $i + 10 }
&b

 > b(10)
10
20

 > $y.?y(b(10))
10
20
True

 > $y.?undef(b(10))
10
Nil


Regards
Marcel



order of execution

2019-10-20 Thread Marcel Timmerman

Hello all,

I've a small question where I want to know what is processed first in 
the following line



$my-object.?"my-method"(some-complex-argument-calculation())


Will the sub 'some-complex-argument-calculation()' always be run even 
when 'my-method' is not available because the sub must be executed 
before the method is called.



In the REPL the sub is called despite a method is not defined. Is it 
also true when compiling?



> class Y { method  y (Int $y) {note $y}}
(Y)

> my Y $y .= new
Y.new

>sub b (Int $i --> Int) { note "$i"; $i + 10 }
&b

> b(10)
10
20

> $y.?y(b(10))
10
20
True

> $y.?undef(b(10))
10
Nil


Regards
Marcel


Re: missing info when a module is not found

2019-10-17 Thread Marcel Timmerman

Hi Vadim,

 I've opened an issue #3238 for this

Regards,
Marcel

Hi Marcel,

Could you, please, open a ticket on github about this? Meanwhile, `perl6 
--ll-exception` could possibly provide you with more details.

Best regards,
Vadim Belman


On Oct 16, 2019, at 1:15 PM, Marcel Timmerman  wrote:

Hi,

I've seen a LTA error message when some module is not found. It only presents a 
line number but not the source file where it is 'use'd.

E.g.

running a perl program

===SORRY!===
Could not find Gnome::Gtk3::ImageMenuItem at line 18 in:
file#/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib
 file#/home/marcel/Languages/Perl6/Projects/gtk-v3/lib
 file#/home/marcel/Languages/Perl6/Projects/gtk-glade/lib
 file#/home/marcel/Languages/Perl6/Projects/Library/lib
 inst#/home/marcel/.perl6
 inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/site
 inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/vendor
 inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/core
 ap#
 nqp#
 perl5#

The project I'm working on is somewhat large and consists of many files. Grep 
didn't do it for me and also the search in the atom editor did not help me out. 
What the possible cause could be is a `require ::($x)` somewhere, where this 
name is not visible, so I'd rather see a module/program name along with the 
line number.

Regards,
Marcel Timmerman



missing info when a module is not found

2019-10-16 Thread Marcel Timmerman

Hi,

I've seen a LTA error message when some module is not found. It only 
presents a line number but not the source file where it is 'use'd.


E.g.

running a perl program

===SORRY!===
Could not find Gnome::Gtk3::ImageMenuItem at line 18 in:
file#/home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib
    file#/home/marcel/Languages/Perl6/Projects/gtk-v3/lib
    file#/home/marcel/Languages/Perl6/Projects/gtk-glade/lib
    file#/home/marcel/Languages/Perl6/Projects/Library/lib
    inst#/home/marcel/.perl6
    inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/site
    inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/vendor
    inst#/mnt/Data/opt/Perl6/rakudo/install/share/perl6/core
    ap#
    nqp#
    perl5#

The project I'm working on is somewhat large and consists of many files. 
Grep didn't do it for me and also the search in the atom editor did not 
help me out. What the possible cause could be is a `require ::($x)` 
somewhere, where this name is not visible, so I'd rather see a 
module/program name along with the line number.


Regards,
Marcel Timmerman


Re: nativecall and variable argument lists

2019-08-29 Thread Marcel Timmerman

On 8/29/19 6:10 PM, Vittore Scolari wrote:

Thank you very much for your examples. After your first message, I 
already had some ideas how to tackle the second question of mine. But 
your 2nd example came first and helps me a lot. Now busy with first,the 
variable arguments list...


Thanks again.
Marcel

In your case, I think that you want something like the following, wish 
you an enjoyable amount of hacking!


sub your_stuff(&callback) {

 ... like pera-int-f before

 my @parameters := &callback.signature.params;

     my $signature = Signature.new(params => (

   Other parameters before

Parameter.new(

  type => Callable,

  sub-signature => &callback.signature),

  ... Other parameters after

  ), returns => int32);

  }

    ... like pera-int-f after

}

*From: *Vittore Scolari 
*Date: *Thursday, 29 August 2019 at 17:48
*To: *Marcel Timmerman , perl6 users 


*Subject: *Re: nativecall and variable argument lists

Hello,

Thanks to the amazing job Lizmat did to implement runtime signatures 
it can be done. You could also probably add some caching of the 
signatures and the functions. I didn’t benchmark. Here the code:


use NativeCall;

sub pera-int-f(Str $format, *@args) {

    state $ptr = cglobal(Str, "printf", Pointer);

    my $signature = Signature.new(

    params => (

    Parameter.new(type => Str),

    |(@args.map: { Parameter.new(type => .WHAT) })

    ),

    returns => int32);

    my &f = nativecast($signature, $ptr);

    f($format, |@args)

}

pera-int-f("Pera + Mela = %d + %d %s\n", 25, 12, "cippas");





nativecall and variable argument lists

2019-08-29 Thread Marcel Timmerman

Hi,

Is there a way to declare a native sub in such a way that it can handle 
variable argument lists? For example sprintf()?


While I'm at it, another question; I need to define native subs which 
can receive a function as an argument to be used as a callback. Why do I 
have to specify the signature of that function? It is quite strict so I 
have to define more than one sub with different callback signatures. An 
example from GTK signals.


gulong
g_signal_connect_object (/|gpointer instance|/,
 /|const gchar *detailed_signal|/,
 /|GCallback 
 
c_handler|/,

 /|gpointer gobject|/,
 /|GConnectFlags 
 
connect_flags|/);



I have to define it like so

my Signature $signal-type = :( N-GObject, OpaquePointer );
my Signature $event-type = :( N-GObject, OpaquePointer, OpaquePointer );

sub g_signal_connect_object(
  N-GObject $widget, Str $signal, Callable $handler
  --> uint64
) {
  my @args = $widget, $signal, $handler, OpaquePointer, 0;
  given $handler.signature {
    when $signal-type { _g_signal_connect_object_signal(|@args) }
    when $event-type { _g_signal_connect_object_event(|@args) }
    default {
  die X::Gnome.new(:message('Handler doesn\'t have proper signature'));
    }
  }
}

sub _g_signal_connect_object_signal(
  N-GObject $widget, Str $signal,
  Callable $handler ( N-GObject, OpaquePointer ),
  OpaquePointer $data, int32 $connect_flags
) returns uint64
  is native(&gobject-lib)
  is symbol('g_signal_connect_object')
  { * }

sub _g_signal_connect_object_event(
  N-GObject $widget, Str $signal,
  Callable $handler ( N-GObject, OpaquePointer, OpaquePointer ),
  OpaquePointer $data, int32 $connect_flags
) returns uint64
  is native(&gobject-lib)
  is symbol('g_signal_connect_object')
  { * }


There are many more handler signatures so it makes it cumbersome to make 
a new definition just because of a different handler signature.



Regards
Marcel


Re: perl6's new name?

2019-08-18 Thread Marcel Timmerman

Hi David,

I think you're right in this. While I like the name chosen by Eliza I 
also thought about the changes which will follow after the renaming. 
Like in documentation with mentions of perl6, websites, books, 
extensions of modules, programs and pod docs etc.


If it comes to renaming, Camelia is the name for me. I strongly oppose 
to Raku or other names referring to Rakudo, Moarvm or other 
implementation of perl6 because we should keep the freedom to change 
that name of the implementation without having to change the name of the 
language it implements. In the past it has been Parrot for example.


Marcel


On 8/11/19 11:14 PM, Eliza wrote:

Hello perl6 world,

I saw the perl6 github issue, just was confused will perl6 change its 
name?





https://github.com/perl6/problem-solving/issues/81


I don't know whether to take this is troll bait or a real issue. Lots 
of people seem to be responding; so in case the issue is real, I will 
make two points against changing the name of Perl 6



From an X.Y major-minor version numbering system standpoint, X is 
incremented whenever the product changes significantly.  In the 
context of computer programming languages, source code incompatibility 
is an obvious criteria for changing X.  If source code is compatible 
after a change, then Y should be changed.  Perl 6 is significantly 
different from Perl 5, and, in general, Perl 6 programs are 
incompatible with the Perl 5 compiler/ interpreter and vice-versa.  
Therefore, the "6" was properly applied and "Perl 6" is correct.



From a practical standpoint, there is too much water under the bridge. 
Name changes need to be done up front (Ruby was done properly in this 
regard).



David


Re: DEPRECATED routine

2019-08-05 Thread Marcel Timmerman

@JJ Merelo,

I filed an the issue: 'extending the documentation of DEPRECATED #2938'



Re: DEPRECATED routine

2019-08-04 Thread Marcel Timmerman

Hi yary,

I thought that it would be nice to give some more information to the 
user at what version the deprecation is started and what the next 
version would be to completely remove the software from the library. It 
is also nice to the developer to be able to remove old code after 
passing the marked version instead of waiting for some period (how long, 
a few months, half a year, or longer?). One can then forget that there 
is still code left to be removed.


Regards,
Marcel




GTK::Simple isn't part of the Rakudo compiler, its use and this thread 
suggests a demand for DEPRECATED in public Perl6.


Could it become a module for user code to import from? Pros, cons, and 
what would it take to promote it to a documented routine?


Marcel what's your use-case for DEPRECATED?

-y


On Sun, Aug 4, 2019 at 8:10 AM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Thank you Brad for the answer, I'll better not use it then. Indeed
I found it interesting because of the version arguments one could
pass to the call, but alas...


The `DEPRECATED` function is a feature of Rakudo, not Perl6.
Which means that how it works, and even its existence could be
changed without warning.

It was added so that the compiler and runtime can mark features
of itself as deprecated.
Because of the design of the compiler and runtime, it leaks out
into the userspace.

It is not in ROAST so it is not Perl6.
`is DEPRECATED` is
https://github.com/perl6/roast/blob/master/S02-types/isDEPRECATED.t

    my $a;
    my $awith;
    sub a     is DEPRECATED              { $a++     };
    sub awith is DEPRECATED("'fnorkle'") { $awith++ };

The only thing this use of `DEPRECATED` shows, is that `is
DEPRECATED` could use a new feature for indicating versions.

On Sun, Aug 4, 2019 at 7:20 AM Marcel Timmerman mailto:mt1...@gmail.com>> wrote:

Hi all,

Studying GTK::Simple if found about the existence of a routine
DEPRECATED which I couldn't find in the Perl6 documents.
Reading from
the code I see that it needs 3 arguments, start version of
deprecation,
version when it is removed and a string like in the 'is
DEPRECATED()' trait.

A use like

sub gtk_builder_add_from_file ( ... ) {
   DEPRECATED(
 'other multi version of gtk_builder_add_from_file',
'0.17.10', '0.20.0'
   );
   ...
}


Gives a result like;

Saw 1 occurrence of deprecated code.


Sub gtk_builder_add_from_file (from Gnome::Gtk3::Builder)
seen at:

/home/marcel/Languages/Perl6/Projects/perl6-gnome-gtk3/../perl6-gnome-native/lib/Gnome/N/X.pm6

(Gnome::N::X), line 109
Deprecated since v0.17.10, will be removed with release v0.20.0!
Please use other version of gtk_builder_add_from_file instead.

Perhaps it should be added to the docs (or I am look in the
wrong spot :-)

Thanks very much for the documentation as it is now
Regards,
Marcel







Re: DEPRECATED routine

2019-08-04 Thread Marcel Timmerman
Thank you Brad for the answer, I'll better not use it then. Indeed I 
found it interesting because of the version arguments one could pass to 
the call, but alas...



The `DEPRECATED` function is a feature of Rakudo, not Perl6.
Which means that how it works, and even its existence could be changed 
without warning.


It was added so that the compiler and runtime can mark features of 
itself as deprecated.
Because of the design of the compiler and runtime, it leaks out into 
the userspace.


It is not in ROAST so it is not Perl6.
`is DEPRECATED` is 
https://github.com/perl6/roast/blob/master/S02-types/isDEPRECATED.t


    my $a;
    my $awith;
    sub a     is DEPRECATED              { $a++     };
    sub awith is DEPRECATED("'fnorkle'") { $awith++ };

The only thing this use of `DEPRECATED` shows, is that `is DEPRECATED` 
could use a new feature for indicating versions.


On Sun, Aug 4, 2019 at 7:20 AM Marcel Timmerman <mailto:mt1...@gmail.com>> wrote:


Hi all,

Studying GTK::Simple if found about the existence of a routine
DEPRECATED which I couldn't find in the Perl6 documents. Reading from
the code I see that it needs 3 arguments, start version of
deprecation,
version when it is removed and a string like in the 'is
DEPRECATED()' trait.

A use like

sub gtk_builder_add_from_file ( ... ) {
   DEPRECATED(
 'other multi version of gtk_builder_add_from_file',
'0.17.10', '0.20.0'
   );
   ...
}


Gives a result like;

Saw 1 occurrence of deprecated code.


Sub gtk_builder_add_from_file (from Gnome::Gtk3::Builder) seen at:

/home/marcel/Languages/Perl6/Projects/perl6-gnome-gtk3/../perl6-gnome-native/lib/Gnome/N/X.pm6

(Gnome::N::X), line 109
Deprecated since v0.17.10, will be removed with release v0.20.0!
Please use other version of gtk_builder_add_from_file instead.

Perhaps it should be added to the docs (or I am look in the wrong
spot :-)

Thanks very much for the documentation as it is now
Regards,
Marcel





DEPRECATED routine

2019-08-04 Thread Marcel Timmerman

Hi all,

Studying GTK::Simple if found about the existence of a routine 
DEPRECATED which I couldn't find in the Perl6 documents. Reading from 
the code I see that it needs 3 arguments, start version of deprecation, 
version when it is removed and a string like in the 'is DEPRECATED()' trait.


A use like

sub gtk_builder_add_from_file ( ... ) {
  DEPRECATED(
    'other multi version of gtk_builder_add_from_file', '0.17.10', '0.20.0'
  );
  ...
}


Gives a result like;

Saw 1 occurrence of deprecated code.

Sub gtk_builder_add_from_file (from Gnome::Gtk3::Builder) seen at:
/home/marcel/Languages/Perl6/Projects/perl6-gnome-gtk3/../perl6-gnome-native/lib/Gnome/N/X.pm6 
(Gnome::N::X), line 109

Deprecated since v0.17.10, will be removed with release v0.20.0!
Please use other version of gtk_builder_add_from_file instead.

Perhaps it should be added to the docs (or I am look in the wrong spot :-)

Thanks very much for the documentation as it is now
Regards,
Marcel


Re: module availability problem

2019-08-01 Thread Marcel Timmerman

Hi Elizabeth,

I've never studied App::Mi6 but what I read in the Readme, this program 
is only a part of what Mi6 does (mi6 release).



Have not looked at the code.  How does that compare to App::Mi6 ??  (which also 
uses CPAN::Uploader::Tiny, btw).


On 31 Jul 2019, at 20:08, Marcel Timmerman  wrote:

Hi JJ Merelo,

Everything is ok now, I can install newest version. Thank you very much for 
finding this error.

In the mean time I've been busy making an uploader yesterday which saves me 
some handwork making the git archive and uploading it to PAUSE using its 
webinterface. It makes use of CPAN::Uploader::Tiny to get it there. As a side 
effect I will never make this mistake again because the name of the archive is 
the name of the directory with the version attached to it. The version is 
retrieved from the META6.json file. For anyone interested, the code is in the 
attachement of this mail. It is free to use and to make modifications but 
without any warranties.

Regards,
Marcel



Re: module availability problem

2019-07-31 Thread Marcel Timmerman

Hi JJ Merelo,

Everything is ok now, I can install newest version. Thank you very much 
for finding this error.


In the mean time I've been busy making an uploader yesterday which saves 
me some handwork making the git archive and uploading it to PAUSE using 
its webinterface. It makes use of CPAN::Uploader::Tiny to get it there. 
As a side effect I will never make this mistake again because the name 
of the archive is the name of the directory with the version attached to 
it. The version is retrieved from the META6.json file. For anyone 
interested, the code is in the attachement of this mail. It is free to 
use and to make modifications but without any warranties.


Regards,
Marcel
#!/usr/bin/env perl6

use v6;
use JSON::Fast;
use CPAN::Uploader::Tiny;

#---
sub MAIN ( *@p6-dirs is copy ) {

  @p6-dirs //= ();

  for @p6-dirs -> $p6-dir {
next unless "$p6-dir".IO.d;

# Check for a Meta file and if there is a git directory
if "$p6-dir/META6.json".IO.r and "$p6-dir/.git".IO.d {
  archive($p6-dir);
}
  }
}

#---
sub archive ( Str $p6-dir is copy ) {

  # remove trailing slash if any
  $p6-dir ~~ s/ '/' $ //;
  chdir($p6-dir);

  # Read the meta file and get the version
  my Hash $meta = from-json('META6.json'.IO.slurp);
  my Str $version = $meta;

  # Remove a leading 'v' if it is used, then keep only 3 version parts
  # separated by 2 dots. CPAN does not like more dots than two.
  $version ~~ s:i/ ^ 'v' //;
  $version ~~ s/ \. \d+ $ // while $version.comb(/\./).join.chars > 2;

  note "Build git archive $p6-dir-$version.tar.gz";
  run 'git', 'archive', "--prefix=$p6-dir-$version/",
  '-o', "../$p6-dir-$version.tar.gz", 'HEAD';

  chdir('..');

  # A file $HOME/.pause must exist with username and password.
  # This file may be encrypted. Two rows are in this file;
  #   user 
  #   password 
  my $uploader = CPAN::Uploader::Tiny.new-from-config($*HOME.add: '.pause');

  try {
$uploader.upload("$p6-dir-$version.tar.gz");
note "$p6-dir-$version.tar.gz is uploaded to PAUSE";

CATCH {
  default {
note "Error: $_.message";
  }
}
  }

  note "Remove $p6-dir-$version.tar.gz";
  unlink "$p6-dir-$version.tar.gz";
}


Re: module availability problem

2019-07-31 Thread Marcel Timmerman

Hi JJ Merelo,

Thanks for your answer. I must have packaged it wrong indeed. I'll try 
to fix that...


M


Just the former is available:

ID|From                             |Package  |Description

0 |Zef::Repository::Ecosystems|Gnome::Gdk3:ver<0.14.5>|Perl6 
Gnome gdk api, Please install Gnome::Gtk3
1 |Zef::Repository::Ecosystems|Gnome::Gdk3:ver<0.14.5>|Perl6 
Gnome gdk api, Please install Gnome::Gtk3
2 |Zef::Repository::Ecosystems|Gnome::Gdk3:ver<0.14.6>|Perl6 
Gnome gdk api, Please install Gnome::Gtk3



The one in modules.perl6.org <http://modules.perl6.org> is correctly 
listed with the 0.17.4 version.But there was a problem when indexing:

---
{
   "authors": [
 "Marcel Timmerman"
   ],
   "build-depends": [
 
   ],

   "depends": [
 "Gnome::N",
 "Gnome::Glib",
 "Gnome::GObject"
   ],
   "description": "Perl6 Gnome gdk api, Please install Gnome::Gtk3",
   "license": "Artistic-2.0",
   "name": "Gnome::Gdk3",
   "perl": "6",
   "provides": {
 "Gnome::Gdk3::Device": "lib/Gnome/Gdk3/Device.pm6",
 "Gnome::Gdk3::Display": "lib/Gnome/Gdk3/Display.pm6",
 "Gnome::Gdk3::Events": "lib/Gnome/Gdk3/Events.pm6",
 "Gnome::Gdk3::Keysyms": "lib/Gnome/Gdk3/Keysyms.pm6",
 "Gnome::Gdk3::RGBA": "lib/Gnome/Gdk3/RGBA.pm6",
 "Gnome::Gdk3::Screen": "lib/Gnome/Gdk3/Screen.pm6",
 "Gnome::Gdk3::Types": "lib/Gnome/Gdk3/Types.pm6",
 "Gnome::Gdk3::Window": "lib/Gnome/Gdk3/Window.pm6"
   },
   "resources": [
 
   ],

   "source-url": 
"http://www.cpan.org/authors/id/M/MA/MARTIMM/Perl6/perl6-gnome-gdk3-0.14.7.tar.gz";,
   "tags": [
 "gnome",
 "gdk"
   ],
   "test-depends": [
     
   ],

   "version": "0.14.6"
}
---
As you see, the source version is OK, the version that was in META6.json when 
packing it was not, apparently, as can be seen here 
too:https://modules.perl6.org/dist/Gnome::Gdk3:cpan:MARTIMM

Since CPAN does not allow you to upload another package with the same 
version, you'll have to bump both up to 0.14.8, I'm afraid...


El mié., 31 jul. 2019 a las 12:16, Marcel Timmerman (<mailto:mt1...@gmail.com>>) escribió:


Hi JJ Merelo,

Takes a couple of hours, in general. What module was it? You
obviously bumped up the version number, right?

Yes I did. Available is Gnome::Gdk3 version 0.14.6 but on CPAN
there's already 0.14.7 uploaded on wed 24th of Juli.


El mié., 31 jul. 2019 a las 11:19, Marcel Timmerman
(mailto:mt1...@gmail.com>>) escribió:

Hi,

I've a problem with zef that it is not installing the newest
module in
town. I had uploaded a module a few days ago to CPAN to
remove a bug but
zef does not notice it. On http://modules.perl6.org/ I also
see that
there isn't the newest yet.

How does the process work and how much time does it take to
get available?

I believe I've seen this answer before somewhere but can't
remember
where and when.

Regards,
Marcel



-- 
JJ




--
JJ




Re: module availability problem

2019-07-31 Thread Marcel Timmerman

Hi JJ Merelo,
Takes a couple of hours, in general. What module was it? You obviously 
bumped up the version number, right?
Yes I did. Available is Gnome::Gdk3 version 0.14.6 but on CPAN there's 
already 0.14.7 uploaded on wed 24th of Juli.


El mié., 31 jul. 2019 a las 11:19, Marcel Timmerman (<mailto:mt1...@gmail.com>>) escribió:


Hi,

I've a problem with zef that it is not installing the newest
module in
town. I had uploaded a module a few days ago to CPAN to remove a
bug but
zef does not notice it. On http://modules.perl6.org/ I also see that
there isn't the newest yet.

How does the process work and how much time does it take to get
available?

I believe I've seen this answer before somewhere but can't remember
where and when.

Regards,
Marcel



--
JJ




module availability problem

2019-07-31 Thread Marcel Timmerman

Hi,

I've a problem with zef that it is not installing the newest module in 
town. I had uploaded a module a few days ago to CPAN to remove a bug but 
zef does not notice it. On http://modules.perl6.org/ I also see that 
there isn't the newest yet.


How does the process work and how much time does it take to get available?

I believe I've seen this answer before somewhere but can't remember 
where and when.


Regards,
Marcel


Re: is inlinable trait missing from docs

2019-07-13 Thread Marcel Timmerman

Thanks very much, I'll look into it

First off, a correction: liz found that the trait_mod: candidate 
for "inlinable" is actually used internally.


Here's a link to the source to get you started, it's got a good 
comment at the start about how rakudo's own inliner works: 
https://github.com/rakudo/rakudo/blob/master/src/Perl6/Actions.nqp#L4193


On top of that, there's MoarVM's spesh, which also does inlining. The 
profiler can tell you what was inlined and what wasn't, and IIRC the 
spesh log can give you more specific info on why an inline was not 
performed in a given case.


HTH
  - Timo

On 13/07/2019 12:51, Marcel Timmerman wrote:

On 7/13/19 12:37 PM, Timo Paulssen wrote:
I wouldn't put "is inlinable" in the docs; it requires the user to 
put a

QAST tree in the value, which isn't a thing an end-user would touch,
IMO. In fact I'm not sure why we have a trait for that at all, since
it's not used anywhere in rakudo's source.

On 13/07/2019 12:33, Marcel Timmerman wrote:

Hi,

I found out about a trait 'is inlinable' when I made a typo in using a
trait on subs. There is no documentation for it so I thought maybe it
is not implemented, experimental or some other reason it is kept out
of the docs. Otherwise it should be documented too.

Great work on the documentation, still learning a lot from it.
Regards,
Marcel

Thanks @Timo

I have used it here and there without any arguments. Can not see if 
it helps.
Btw, is rakudo finding out itself if routines are inlinable and what 
algorithm is it using? I have this question to see if one can 
influence this process and nudge the routine into inlining.






Re: is inlinable trait missing from docs

2019-07-13 Thread Marcel Timmerman

On 7/13/19 12:37 PM, Timo Paulssen wrote:

I wouldn't put "is inlinable" in the docs; it requires the user to put a
QAST tree in the value, which isn't a thing an end-user would touch,
IMO. In fact I'm not sure why we have a trait for that at all, since
it's not used anywhere in rakudo's source.

On 13/07/2019 12:33, Marcel Timmerman wrote:

Hi,

I found out about a trait 'is inlinable' when I made a typo in using a
trait on subs. There is no documentation for it so I thought maybe it
is not implemented, experimental or some other reason it is kept out
of the docs. Otherwise it should be documented too.

Great work on the documentation, still learning a lot from it.
Regards,
Marcel

Thanks @Timo

I have used it here and there without any arguments. Can not see if it 
helps.
Btw, is rakudo finding out itself if routines are inlinable and what 
algorithm is it using? I have this question to see if one can influence 
this process and nudge the routine into inlining.




is inlinable trait missing from docs

2019-07-13 Thread Marcel Timmerman

Hi,

I found out about a trait 'is inlinable' when I made a typo in using a 
trait on subs. There is no documentation for it so I thought maybe it is 
not implemented, experimental or some other reason it is kept out of the 
docs. Otherwise it should be documented too.


Great work on the documentation, still learning a lot from it.
Regards,
Marcel


Re: gtk widget?

2019-04-24 Thread Marcel Timmerman
Please take note that the package is using GTK::V3 and that quite a few 
things are different compared to GTK::Simple. For that information 
please look at https://github.com/MARTIMM/gtk-v3


Good luck (because the documentation is still in its infancy :-o)
Marcel

On 4/22/19 2:56 PM, Timo Paulssen wrote:

Please check out Marcel Timmermann's GTK::Glade module. Here's the readme:

https://github.com/MARTIMM/gtk-glade

Sadly, modules.perl6.org is currently not available, however, you can
download the distribution here:

https://www.cpan.org/authors/id/M/MA/MARTIMM/Perl6/gtk-glade-0.8.3.tar.gz

or you can git clone the repository and "zef install ." from inside it.

There's a little pdf file in the docs/ folder about using the module itself.

In order to build a glade file to use with this library, you can install
the program "glade". This allows you to graphically put a GUI together.

https://glade.gnome.org/


Good Luck!
   - Timo


On 22/04/2019 05:44, ToddAndMargo via perl6-users wrote:

Hi All,

I see

https://github.com/perl6/gtk-simple/tree/master/examples

but I have no clue what is going on.

Is there some kind of gtk widget that you can graphically
design these windows with?

Many thanks,
-T



Re: hash copy

2019-03-24 Thread Marcel Timmerman

Hi Brad and Yari,

Thanks very much for your in depth explanations.

Regards,
Marcel


hash copy

2019-03-24 Thread Marcel Timmerman

Hi,

I was wandering if the following is an assignment or a binding (or 
binding of the entries);


my Hash $sleep-wait = { :s1(4.3), :s2(2.1), :s3(5.3), :s4(10.4), :s5(8.7),};

my Hash $sleep-left = $sleep-wait;



I noticed that in the following piece of code the $sleep-wait hash 
entries were set to 0
I had to explicitly do a copy to let it function correctly; 'my Hash 
$sleep-left = %(|$sleep-wait);'

Also cloning didn't work.


use v6;

my Hash $sleep-wait = {

  :s1(4.3), :s2(2.1), :s3(5.3), :s4(10.4), :s5(8.7),

};

my Hash $sleep-left = $sleep-wait;

loop {

  # get shortest sleep

  my $t = 1_000_000.0;

  my $s;

  for $sleep-left.keys -> $k {

    if $sleep-left{$k} < $t {

  $t = $sleep-left{$k};

  $s = $k;

    }

  }

  # set back to original time

  $sleep-left{$s} = $sleep-wait{$s};

  note "Reset entry $s to $sleep-left{$s} (from $sleep-wait{$s})";

  # adjust remaining entries

  for $sleep-left.keys -> $k {

    next if $s eq $k;

    $sleep-left{$k} -= $t;

    $sleep-left{$k} = $sleep-wait{$k} if $sleep-left{$k} <= 0;

  }

  note "sleep for $t sec, entry $s";

  sleep $t;

}


perl version;

This is Rakudo version 2018.12-363-ga1c2e20d7 built on MoarVM version 
2018.12-117-gdcafbc4c7

implementing Perl 6.d.


Regards,
Marcel


=begin comment as replacement for =begin data

2018-05-21 Thread Marcel Timmerman

Hi,

I was trying to find a way to have data stored in the program script 
itself a la perl5 __DATA__. Perl6 has the =data pod structures to do 
that. But after a first test I got an error using $=data saying that it 
was not yet implemented. But, as the saying goes, there's more than one 
way to do it!


First I still wanted to use the '=begin data' and '=end data' pod 
statements to store data and just search through the pod data myself. 
The problem I found however was that the newline characters were removed 
from the text. This is inconvenient. Looking at other pod thingies I saw 
that the pod comment was very usable in that everything was left as it 
was typed in. I've developed a small sub which makes use of comment 
blocks and interprets them as a data block.


E.g.

=begin comment :!comment :type

# test van data
foo 1

# second line
bar 2

=end comment

# get and use the data
my Str $foo-data = get-data('fooData');
for $foo-data.lines -> $line {
  say "Data line: $line";
}

# Program returns;
#Data line: foo 1
#Data line: bar 2

A few things to mention here;
1) :!comment is checked by the sub so it must be there. It is also a 
sign to the reader that this block is not used to show comments.
2) :fooData is the key to use to search for data. More than one data 
block is then possible and other (real) comments are not processed.
3) The sub is filtering out empty lines and comment lines (starting with 
'#').


The sub is shown below;

sub get-data ( Str:D $content-key --> Str ) {

  my Str $content;

  # search through the pod structure
  for @$=pod -> $pd {

    # search for 1) pod comment block, 2) :!comment and 3) the users key
    if $pd ~~ Pod::Block::Comment and
   !$pd.config and
   $pd.config eq $content-key {

  $content = $pd.contents[0];
  last;
    }
  }

  # remove comments
  $content ~~ s:g/\s* '#' .*? $$//;

  # remove empty lines
  $content ~~ s:g/^^ \s* $$//;
  $content ~~ s:g/\n\n+/\n/;
  $content ~~ s:g/^\n+//;
  $content ~~ s:g/\n+$//;

  $content
}


You can get this program from a gist at github here;
https://gist.github.com/MARTIMM/516b3ade0500428cedc28ae86fad6a1b

Hopefully anyone can profit from this code,
cheers,
Marcel


Re: latest rakudo srtar not found

2018-04-16 Thread Marcel Timmerman

On 04/16/2018 05:02 PM, Siavash wrote:

Hi,

Rakudo.org was redesigned, apparently the new URL for you is:
https://rakudo.org/latest/star/win64

The new download page:
https://rakudo.org/files

Thanks, these links help
Regards,
Marcel


latest rakudo srtar not found

2018-04-16 Thread Marcel Timmerman

Hi,

I was used to download the latest rakudo star install file for testing 
on appveyor using url 
http://rakudo.org/downloads/star/rakudo-star-latest-x86_64 (JIT).msi. 
Messages returned are


Error downloading remote file: One or more errors occurred.
Inner Exception: Remote server returned 404: Not Found

Is the file stored at another location perhaps?

Regards
Marcel



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

2017-10-31 Thread Marcel Timmerman

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 Marcel Timmerman

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 Marcel Timmerman

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_code (in

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

2017-10-18 Thread Marcel Timmerman

@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


thread behavior

2017-09-04 Thread Marcel Timmerman

Hi,

I was wondering about the following,

When an Exception is thrown in a thread and is CATCHed  in another 
object, will that block be run in the same thread as the Exception is 
thrown?


Thanks in advance,
Marcel


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

2017-07-22 Thread Marcel Timmerman

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.




450-find.t
Description: Perl program


Re: [perl #131493] changed type of variable

2017-06-03 Thread Marcel Timmerman
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 Marcel Timmerman

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 Marcel Timmerman

On 06/03/2017 11:36 AM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote:

say IntStr ~~ Str


> say Str ~~ IntStr
False


Re: list named argument in MAIN

2017-06-01 Thread Marcel Timmerman

On 06/01/2017 03:03 PM, H.Merijn Brand wrote:

On Thu, 1 Jun 2017 14:11:47 +0200, Timo Paulssen 
wrote:


It seems like this only works if you supply --dirs= multiple times

 perl6 -e 'sub MAIN (List :$dirs=[]) { .say for @$dirs }' --dirs=d1 
--dirs=d2 --dirs=d3

 d1
 d2
 d3

took me a bit as it needs both .List *and* flat. Got help on IRC

$ perl6 -e 'sub MAIN (List :$dirs=[]) { .say for flat @$dirs.List».split: /","/ 
}' --dirs=d1 --dirs=d2 --dirs=d3,d4,d5
d1
d2
d3
d4
d5



Re: list named argument in MAIN

2017-06-01 Thread Marcel Timmerman

On 06/01/2017 02:11 PM, Timo Paulssen wrote:

It seems like this only works if you supply --dirs= multiple times

 perl6 -e 'sub MAIN (List :$dirs=[]) { .say for @$dirs }' --dirs=d1
--dirs=d2 --dirs=d3

 d1
 d2
 d3

HTH
   - Timo


Thanks Timo,

Just tested this and it works. But there is still a problem and maybe a 
bug. It should accept a single option to have a list with one item. In 
that case it shows the usage message.


FWIW, I've cooked up a short piece to have it my way


my @a;
for @*ARGS -> $a {
  if $a ~~ m/^ '--dirs'/ {
for $a.split('=')[1].split(',') -> $d {
  @a.push("--dirs=$d");
}
  }

  else {
@a.push($a);
  }
}
@*ARGS = @a;


sub MAIN (List :$dirs=[]) { }

Regards


list named argument in MAIN

2017-06-01 Thread Marcel Timmerman

Hi,

How can I read a list of items from the command line. Something like;

mkdir.pl6 --dirs=d1,d2,d3


I thought I could do something like;

sub MAIN (List :$dirs=[]) {
  mkdir($_) for @$dirs;
}

But it keeps displaying the usage message


Greetings,
Marcel


Re: run() not capturing exitcode properly?

2017-05-30 Thread Marcel Timmerman

Hi

Exit code is set after closing one of the output channels. If you close 
both,  the errorcode is reset to 0 again. (This might be a bug though)


my $p = run "ls", "dadsad", :out, :err;
say $p.err.lines;
---> (ls: cannot access 'dadsad': No such file or directory)

$p.out.close;
$p.exitcode;
---> 2


Marcel Timmerman


Re: naming a class

2017-05-28 Thread Marcel Timmerman

On 05/28/2017 12:04 PM, Elizabeth Mattijsen wrote:

On 28 May 2017, at 11:49, Marcel Timmerman  wrote:
I've a question about naming a specific class. It is about the type Decimal128 
which I need in BSON. For the moment I want it to hold a number and in BSON to 
encode and decode it to a byte stream. Later I can add specific operations and 
other known decimal types. I am thinking of the following names;

Math::Decimal::D128
Math::Decimal::D64
Math::Decimal::D32

For the 128, 64 and 32 bit decimal types. Or should I drop the Math:: part.

The other question I have is the following; I know about the _Decimal128 type 
in C (gcc). Is it also a standard type in C on windows and mac? In that case I 
could try to go native.

Apart from the naming, isn’t Decimal64 the same as “num64” in Rakudo?  And 
Decimal32 the same as “num32” ?  If so, I think there’s already an outstanding 
RT for not supporting “num128” in Rakudo.  Perhaps it would be better to focus 
on supporting this in MoarVM directly?



Liz


Hi Liz,

I've understood that the representation is a bit different. The num* 
types are based on floating point layout and the decimal* is based on a 
densely packed decimal (a kind of packed BCD). For the 128 bit version 
it would represent 34 digits coefficient.


Still, when I get something running it could be a new type in moarvm 
later on (help is needed though to lead the way in moarvm).


Marcel


naming a class

2017-05-28 Thread Marcel Timmerman

Hi,

I've a question about naming a specific class. It is about the type 
Decimal128 which I need in BSON. For the moment I want it to hold a 
number and in BSON to encode and decode it to a byte stream. Later I can 
add specific operations and other known decimal types. I am thinking of 
the following names;


Math::Decimal::D128
Math::Decimal::D64
Math::Decimal::D32

For the 128, 64 and 32 bit decimal types. Or should I drop the Math:: part.

The other question I have is the following; I know about the _Decimal128 
type in C (gcc). Is it also a standard type in C on windows and mac? In 
that case I could try to go native.


Regards,
Marcel


problem converting Inf and NaN

2017-05-27 Thread Marcel Timmerman

Hi,

In perl6 version 2017.04.3-287-g3e7675a built on MoarVM version 
2017.04-64-g6d5ea04

implementing Perl 6.c. I observe the following;



my Num $num = Inf;
my FatRat $f = $num.FatRat;
Type check failed in assignment to $f; expected FatRat but got 
Rational[Num,Int] (?)

  in block  at  line 1

Inf.WHAT;# (Num)
Inf.FatRat.WHAT  # (Rational[Num,Int])

It boils down to not converting to FatRat while a defined number does;
my Num $num = 2.3e3;
$num.FatRat.WHAT;# (FatRat)


This is the same for NaN.

If this is defined behavior, then there is no way to set NaN or Inf for 
FatRat (and for Rat too). Is there another way to accomplish this?



Thanks,
Marcel


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

2017-05-02 Thread Marcel Timmerman

Thanks very much
Marcel


Re: [perl #130492] subtest fails on windows

2017-01-03 Thread Marcel Timmerman
Sorry for the false alarm. I need to find out how to get the latest version 
on appveyor. It was fixed on a very early date, 2016.4 if I recall it 
correctly,


Anyways, thanks
Marcel


On January 3, 2017 2:50:31 PM "Zoffix Znet via RT" 
 wrote:



On Tue, 03 Jan 2017 00:28:25 -0800, mt1...@gmail.com wrote:

running tests on the Appveyor system I noticed the following;


prove -v --merge --exec "perl6 -Ilib" t
t\100-th.t ..
Type check failed in binding &subtests; expected Callable but got Str
("instantiate")
in sub subtest at
C:\rakudo\share\perl6\sources\C712FE6969F786C9380D643DF17E85D06868219E
(Test) line 292
in block  at t\100-th.t line 6
Dubious, test returned 1 (wstat 256, 0x100)


It was the first time I switched the arguments to subtest because I've
seen others doing it and I like it better.

Earlier I did "subtest { ... tests ... }, 'description';"
Here I did "subtest 'description', {... tests ... };"

On linux there are no problems;

Regards
Marcel


That's because on Windows you're using Rakudo that's too old. Upgrade to 
version 2016.07 or newer.


In the future, please include versions of the compiler you're using. You 
can get those by running perl6 -v







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

2016-05-30 Thread Marcel Timmerman

Hi,
Yes you can close it.

Thanks,
Marcel



On May 29, 2016 10:32:16 PM "Sam S. via RT"  
wrote:


Does this mean that the current IO::Socket::INET bahavior is fine and the 
ticket can be closed?





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

2016-05-01 Thread Marcel Timmerman

Hi,
Thanks for the explanation, sorry for creating the bug entry.
regards,
Marcel


On May 1, 2016 1:28:58 PM "Sam S. via RT"  wrote:

PS: Or if you don't like the `hash` keyword, you can use the  %( )  
contextualizer which does the same thing:


my Hash $h = %( f1 => $_ );





Re: Union

2016-04-11 Thread Marcel Timmerman

Hi

Thanks for your answer. I was thinking in perl6, I should have been more 
explicit. At the moment I am converting Num to a float representation in my 
BSON module and was wondering if there where easier ways and maybe faster too.

Regards,
Marcel






--- Forwarded message ---
From: Marcel Timmerman 
Date: April 11, 2016 8:28:22 PM
Subject: Re: Union
To: Parrot Raiser <1parr...@gmail.com>

Hi
Thanks for your answer. I was thinking in perl6, I should have been more
explicit. At the moment I am converting Num to a float representation in my
BSON module and was wondering if there where easier ways and maybe faster too.

Regards,
Marcel






Union

2016-04-11 Thread Marcel Timmerman

Hi,

While the perl language already offers so much I have a question not found 
in perl


Is there anything like the C union to do an easy mapping from some native 
variable to a buf of the same number of bytes? This is a nice helper for 
pack/unpack for native values. It is important to know about little/big 
endian in such cases.


Greetings
Marcel




Re: [perl #126688] bug detecting circular dependencies

2016-03-27 Thread Marcel Timmerman
There should be already several bug reports mentioning this. I and someone 
else have reported this. I forgot the bug numbers though, I am on a 
vacation and therefore not able to find the bug number, sorry


Marcel Timmerman


On March 27, 2016 6:47:08 PM Carl Mäsak via RT 
 wrote:


 I like to (possibly superstitiously) have a test file with 
just use-ok in it to catch any weird  dependency issues
 RabidGravy: all I can say is, I've never used `use-ok`, not even in 
a separate file, and I don't feel that *not* getting the `use` error 
separately has in any way detracted from the testing experience.
 in fact, the usual reason I get `use` errors in the first place is 
because I forgot to `export PERL6LIB=lib` :)
 and that's easily fixed, no matter whether I have a separate test 
file with `use-ok` or not
 I think, for me, it goes back to testing very large programs 
using moose where it was easy to miss circular dependencies at a distance 
(e.g. where A uses B uses C uses D uses A) and things would stop loading 
under certain circumstances
 RabidGravy: I was going to say that "we don't allow that kind of 
circular dependencies to happen in Perl 6"
 RabidGravy: ...but then I tried it, and it puts Rakudo in an 
infinite loop :(

 just A.pm containing `use B;` and vice versa triggers it
* masak submits rakudobug
 if nothing else, it's a crappy default
 masak: there's a rakudobug open already
 oh, ok
* masak stands down
 if I find it, I can add this discussion
 ah, https://rt.perl.org/Ticket/Display.html?id=126688