rakudo Github contribution chart
rakudo Github Stats
rakudo Most Used Languages

Activity

03 Jul 2022

Niner

Implement andthen, orelse and notandthen in RakuAST

Pushed On 03 Jul 2022 at 02:04:58

Niner

Stub support for no ; statements

Pushed On 03 Jul 2022 at 02:04:58

Niner

Fix $_ not containing exception in default blocks withing packages

A default handler did not get an implicit block topic ($). This made the QAST compiler find the comp unit's $ lexical instead of the nearest one. That $_ however did not contain the exception when we are in a package as package blocks get their own $. Fix by giving the default block an implicit topic, defaulting to the $ of the outer lexical scope, i.e. the CATCH block's.

Pushed On 03 Jul 2022 at 11:17:59
Issue Comment

Vrurg

Implement coercion via new-disp

All cases covered except for Type1(Type2()) where recursive dispatching is required.

Forked On 03 Jul 2022 at 02:52:43

Vrurg

I have it as a draft for now because if time allows I'd like to finish @jnthn work on return values where currently the only allowed method of coercion is .Type.

Commented On 03 Jul 2022 at 02:52:43
Issue Comment

Vrurg

Implement coercion via new-disp

All cases covered except for Type1(Type2()) where recursive dispatching is required.

Forked On 03 Jul 2022 at 02:49:08

Vrurg

Benchmark Results

master here is the latest master branch with @lizmat optimizations. Columns with Loop are full timing of loops. Pure correspond to the pure timing of the coercion infrastructure code.

What I can say: new-disp is still amazing me!

| Compared To | .Type Loop | .Type Pure | .COERCE Loop | .COERCE Pure | .new Loop | .new Pure | | --- | --- | --- | --- | --- | --- | --- | | 2022.06 | 1.97 | 2.45 | 6.39 | 15.36 | 2.76 | 13.13 | | master | 1.24 | 1.36 | 4.41 | 9.99 | 2.60 | 11.46 |

Here are results for @lizmat optimizations too, based on the same set of data:

| Compared To | ".Type Loop" | ".Type Pure" | ".COERCE Loop" | ".COERCE Pure" | ".new Loop" | ".new Pure" | | -- | -- | -- | -- | -- | -- | -- | | 2022.06 | 1.59 | 1.80 | 1.45 | 1.54 | 1.06 | 1.15 |

The interesting observation here is about COERCE and new. Since these are the least used coercion methods they're considered later in the original coercion code in metamodel. Correspondingly, it takes most time to invoke them, what is clearly visible from the second table. Hence, the numbers in the first table where new-disp allows to bypass all the other checks and invoke the methods nearly immediately thus sparing us a lot of CPU cycles.

I could expect the timing to be even better for new since the coercion code invoking it has to use try/CATCH in order to intercept X::Constructor::Positional and convert it into no coercion method found error. Thus, the thunk becomes un-inlinable. Consequently, new is still 2.3 times slower than COERCE (BTW, it is 2.66 times slower on master).

But because new is barely used for this purpose, and because COERCE is supposed to be the primary method of indirect coercion, I think there is no need in getting rid of the exception handling.

Commented On 03 Jul 2022 at 02:49:08
Issue Comment

Vrurg

Implement coercion via new-disp

All cases covered except for Type1(Type2()) where recursive dispatching is required.

Forked On 03 Jul 2022 at 02:21:39

Vrurg

Benchmarks Methodology

The script used for benchmarking is provided below. It outputs CSV-like output which can be later pulled into a spreadsheet. The benchmark first warms up the VM, then does the actual test. Each series includes:

  1. Bare loop speed to provide the impression of how much the whole coercion takes minus the loop itself and variable assignment.
  2. Coercion via $obj.Type
  3. Via COERCE method
  4. Via new method

For each of 2,3,4 items two times are measured: the actual timing of the loop, including the assignment and loop times; and the pure time the coercion protocol takes, excluding the loop, the assignment, and even the time corresponding coercion method takes. I.e. it is the pure time of the coercion infrastructure code, user code excluded.

Series are then repeated five times. After importing the data into a spreadsheet I take the minimal time for each measurement based on the idea that anything above that are overheads of the system and the language core like GC kicking in or alike.

class CNew {
    has $.val;
    multi method new(Int:D $val) {
        samewith :$val;
    }
}

class CCOERCE {
    has $.val;
    multi method COERCE(Int:D $val) {
        self.new :$val;
    }
}

class CType {
    has $.val;
    method Int { $.val }
}

constant WARM-UPS = 10000;
constant REPETITIONS = 100000;

sub bench-type($warmup = False) {
    my $reps = $warmup ?? WARM-UPS !! REPETITIONS;

    my $c = CType.new(:val(11));

    my $dst = now;
    for ^$reps {
        my $int = $c.Int;
    }
    my $dtime = now - $dst;

    my $cst = now;
    for ^$reps {
        my $int = Int($c);
    }
    my $ctime = now - $cst;

    $ctime, ($ctime - $dtime)
}

sub bench-COERCE($warmup = False) {
    my $reps = $warmup ?? WARM-UPS !! REPETITIONS;
    my $dst = now;
    for ^$reps {
        my $c = CCOERCE.COERCE($_);
    }
    my $dtime = now - $dst;

    my $cst = now;
    for ^$reps {
        my $c = CCOERCE($_);
    }
    my $ctime = now - $cst;

    $ctime, ($ctime - $dtime)
}

sub bench-new($warmup = False) {
    my $reps = $warmup ?? WARM-UPS !! REPETITIONS;
    my $dst = now;
    for ^$reps {
        my $c = CNew.new($_);
    }
    my $dtime = now - $dst;

    my $cst = now;
    for ^$reps {
        my $c = CNew($_)
    }
    my $ctime = now - $cst;

    $ctime, ($ctime - $dtime)
}

sub bench-loop($warmup = False) {
    my $reps = $warmup ?? WARM-UPS !! REPETITIONS;
    my $st = now;
    for ^$reps {
        my $v = $_;
    }
    my $ftime = now - $st;
}

my @h = ('Bare Loop', '.Type Loop', '.Type Pure', '.COERCE Loop', '.COERCE Pure', '.new Loop', '.new Pure');
say @h.map(*.raku).join(", ");

for ^5 {
    my @res;
    bench-loop(True);
    @res.push: bench-loop;

    bench-type(True);
    @res.append: bench-type;

    bench-COERCE(True);
    @res.append: bench-COERCE;

    bench-new(True);
    @res.append: bench-new;
    say @res.join(", ");
} 

Commented On 03 Jul 2022 at 02:21:39
Pull Request

Vrurg

Implement coercion via new-disp

Created On 03 Jul 2022 at 01:18:28

Niner

Variable declarations must be terms as well

Declarations can be part of expressions and yield a value, so they must be expressions, too.

Pushed On 02 Jul 2022 at 05:13:40

Niner

Fix potential infinite loop on do { } blocks run at BEGIN time

A BEGIN time call to a do { } block caused us to clone the block before it was linked, thus the clone was missing from the list of clones to update on dynamic compilation of the block itself.

Pushed On 02 Jul 2022 at 03:54:56

Niner

Implement support for simple Whatever currying in RakuAST

Pushed On 02 Jul 2022 at 03:54:56

Niner

Implement currying of WhateverCode (i.e. curried expressions)

Pushed On 02 Jul 2022 at 03:54:56

Niner

Fix copy pasta in RakuAST::ApplyDottyInfix

Pushed On 02 Jul 2022 at 03:54:56

Lizmat

Rename "span" to "snip"

Pushed On 02 Jul 2022 at 10:54:04
Issue Comment

TimToady

Implement Haskell's "span" in 6.e

Inspired by https://stackoverflow.com/questions/72809469/in-raku-how-does-one-write-the-equivalent-of-haskells-span-function

This implements both the method as well as the sub version of "span".

For more flexibility, the condition can also be a List of conditions (in the sub case), or just have multiple conditions (in the method case).

.say for span * < 10, 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2 20 4)

.say for span (* < 10, * < 20), 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2)
(20 4)

.say for (2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4).span( * < 5, * < 10 );
(2 2 2)
(5 5 7)
(13 9 6 2 20 4) 

Span documentation: https://hackage.haskell.org/package/base-4.16.1.0/docs/Prelude.html#v:span

Forked On 01 Jul 2022 at 10:14:12

TimToady

I like it. It's cute, but I don't think it falls into the category of "You think that's cute today."

Larry

On Fri, Jul 1, 2022 at 3:41 PM Elizabeth Mattijsen @.***> wrote:

How about "snip" ?

— Reply to this email directly, view it on GitHub https://github.com/rakudo/rakudo/pull/4976#issuecomment-1172663092, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHSYR7Q77OI4IQWZ22NWDVR5CXDANCNFSM52LUL7IQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Commented On 01 Jul 2022 at 10:14:12
Issue Comment

Lizmat

Implement Haskell's "span" in 6.e

Inspired by https://stackoverflow.com/questions/72809469/in-raku-how-does-one-write-the-equivalent-of-haskells-span-function

This implements both the method as well as the sub version of "span".

For more flexibility, the condition can also be a List of conditions (in the sub case), or just have multiple conditions (in the method case).

.say for span * < 10, 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2 20 4)

.say for span (* < 10, * < 20), 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2)
(20 4)

.say for (2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4).span( * < 5, * < 10 );
(2 2 2)
(5 5 7)
(13 9 6 2 20 4) 

Span documentation: https://hackage.haskell.org/package/base-4.16.1.0/docs/Prelude.html#v:span

Forked On 01 Jul 2022 at 07:41:24

Lizmat

How about "snip" ?

Commented On 01 Jul 2022 at 07:41:24
Issue Comment

Locriacyber

Feature Request: Pass CStruct by value

The Problem

Currently, there is no way to pass struct by value to C function with NativeCall.

For example:

#include <stdio.h>

typedef struct {
    int a;
    int b[3];
    int c;
} InlinedArrayInStruct;

void print_struct_by_pointer(InlinedArrayInStruct *ss) {
    InlinedArrayInStruct s = *ss;
    printf("%d, (%d, %d, %d), %d\n", s.a, s.b[0], s.b[1], s.b[2], s.c);
}

void print_struct_by_value(InlinedArrayInStruct s) {
    printf("%d, (%d, %d, %d), %d\n", s.a, s.b[0], s.b[1], s.b[2], s.c);
} 

Currently, there is no way to call print_struct_by_value in the language.

Related issues with CStruct: #4969 #4961 https://github.com/rakudo/rakudo/issues/4022

Environment

  • Compiler version (perl6 -v or raku -v): 2022-06

Forked On 01 Jul 2022 at 01:41:07

Locriacyber

@niner people over IRC told me to ask you about NativeCall.

From what I understand, I think we need a new (not backwards-compatible) FFI for Raku that allows passing by reference. It is more orthogonal to remove HAS and make has mean "include by value".

That aside, I want to help writing the new FFI for Raku (using libffi). Please give me guidance on how the current NativeCall works in Raku. I tracked it down to codegen in MoarVM, and then I was lost. How does MoarVM use libc anyway?

Commented On 01 Jul 2022 at 01:41:07
Issue Comment

Jnthn

Implement Haskell's "span" in 6.e

Inspired by https://stackoverflow.com/questions/72809469/in-raku-how-does-one-write-the-equivalent-of-haskells-span-function

This implements both the method as well as the sub version of "span".

For more flexibility, the condition can also be a List of conditions (in the sub case), or just have multiple conditions (in the method case).

.say for span * < 10, 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2 20 4)

.say for span (* < 10, * < 20), 2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4;
(2 2 2 5 5 7)
(13 9 6 2)
(20 4)

.say for (2, 2, 2, 5, 5, 7, 13, 9, 6, 2, 20, 4).span( * < 5, * < 10 );
(2 2 2)
(5 5 7)
(13 9 6 2 20 4) 

Span documentation: https://hackage.haskell.org/package/base-4.16.1.0/docs/Prelude.html#v:span

Forked On 01 Jul 2022 at 12:54:09

Jnthn

Functionality wise, it seems like a useful addition. I'm not really sure about the name span; none of the meanings of the verb "to span" seem to really describe what this does. Maybe something more like "partition"?

Commented On 01 Jul 2022 at 12:54:09

Lizmat

Generalize the matcher on span

Instead of just allowing a Callable, go for smart-matching instead.

.say for (2, 2, 2, 5, 5, "a", "b", "c").span: Int;
(2 2 2 5 5)
(a b c)

.say span Int, 2, 2, 2, 5, 5, "a", "b", "c");
(2 2 2 5 5)
(a b c) 

Pushed On 01 Jul 2022 at 12:49:12
Issue Comment

M-dango

.raku method sorts maps and hashes but not sets and bags

I noticed that the raku method on hashes and maps will sort the keys for you: https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Hash.pm6#L176 https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Map.pm6#L186

However this doesn't seem to happen for sets and bags: https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Setty.pm6#L151 https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Baggy.pm6#L283

I had not expected the former to be sorted, but I think it would be nice if sorting with the .raku method on Associatives was a consistent behaviour.

Forked On 01 Jul 2022 at 11:58:39

M-dango

My current use is for output into .raku files, so the sorting is nice to have so diffs don't change each time. When I first used the method on a Bag the output being different each time was unsurprising, and I changed my approach to account for it, but when I later noticed Hash was being sorted, it drove me to open this ticket.

Its less an issue and more a question of "why this one and not that one?"

Commented On 01 Jul 2022 at 11:58:39
Pull Request

Lizmat

Implement Haskell's "span" in 6.e

Created On 01 Jul 2022 at 06:30:52
Create Branch
Lizmat In rakudo/rakudo Create Branchlizmat-span

Lizmat

🦋 Rakudo – Raku on MoarVM, JVM, and JS

On 01 Jul 2022 at 06:30:40
Issue Comment

Kaiepi

Make unsuccessful connect fail rather than die

Spotted in https://stackoverflow.com/questions/72639883/how-to-deal-with-exceptions-in-iosocketinet

There is no documentation or tests covering the behaviour of a failed connect. It is actually the nqp::connect that throws (which turns out also to be not documented BTW).

Having it return a Failure feels more natural indeed.

Forked On 01 Jul 2022 at 05:55:02

Kaiepi

I'd like for IO::Socket::INET's connect/listen to err to fail like its own IO::Socket read, recv, write, close does in the future, if only to simplify chaining of operations, e.g.:

with IO::Socket::INET.connect: '127.0.0.1', 23 -> $client {
    LEAVE { $client.close }
    [andthen] gather take $client.print("$_$?NL") for ^100
} 

But I'd rather not see such a change break networking code.

Commented On 01 Jul 2022 at 05:55:02
Issue Comment

TimToady

.raku method sorts maps and hashes but not sets and bags

I noticed that the raku method on hashes and maps will sort the keys for you: https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Hash.pm6#L176 https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Map.pm6#L186

However this doesn't seem to happen for sets and bags: https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Setty.pm6#L151 https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Baggy.pm6#L283

I had not expected the former to be sorted, but I think it would be nice if sorting with the .raku method on Associatives was a consistent behaviour.

Forked On 01 Jul 2022 at 01:20:08

TimToady

I dunno about that—I think the main purpose of .raku is not serialization, and in fact given compiler performance it's a terrible way to serialize....unless you want it to be human readable, in which case all these things should be sorted because you're likely to install such code into another program, and if you ever want to modify that program, ordering is rather beneficial to the next programmer that will see the data. Mainly, .raku is there to present a much less ambiguous representation to the user than a .gist might, when the user is likely to not mind the extra punctuation.

Larry

On Thu, Jun 30, 2022 at 8:54 PM rir @.***> wrote:

It would be nice only sometimes.

Since the purpose of .raku is to create a string from which an instance can be resurrected, it would be inefficient to impose order on an unordered collection. Besides Associative is just a role.

— Reply to this email directly, view it on GitHub https://github.com/rakudo/rakudo/issues/4975#issuecomment-1171810030, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABHSYVQ3ITCK4RJH7APIUTVRY6VFANCNFSM52HRN6HA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Commented On 01 Jul 2022 at 01:20:08
Issue Comment

0rir

.raku method sorts maps and hashes but not sets and bags

I noticed that the raku method on hashes and maps will sort the keys for you: https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Hash.pm6#L176 https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Map.pm6#L186

However this doesn't seem to happen for sets and bags: https://github.com/rakudo/rakudo/blob/90d876a3fdaa5b381f2e765060aac67fe7e923ab/src/core.c/Setty.pm6#L151 https://github.com/rakudo/rakudo/blob/7cf26457288a245646e134fa3fbf6488a7d0d28f/src/core.c/Baggy.pm6#L283

I had not expected the former to be sorted, but I think it would be nice if sorting with the .raku method on Associatives was a consistent behaviour.

Forked On 01 Jul 2022 at 12:54:29

0rir

It would be nice only sometimes.

Since the purpose of .raku is to create a string from which an instance can be resurrected, it would be inefficient to impose order on an unordered collection. Besides Associative is just a role.

Commented On 01 Jul 2022 at 12:54:29
Issue Comment

Vrurg

Make unsuccessful connect fail rather than die

Spotted in https://stackoverflow.com/questions/72639883/how-to-deal-with-exceptions-in-iosocketinet

There is no documentation or tests covering the behaviour of a failed connect. It is actually the nqp::connect that throws (which turns out also to be not documented BTW).

Having it return a Failure feels more natural indeed.

Forked On 30 Jun 2022 at 09:12:35

Vrurg

Turns out, this PR requires spec changes. Our new flapper, S32-io/socket-recv-vs-read.t, is built around the fact that a new connection throws on error. Same assumption is made about listen, BTW.

I'm considering reverting this PR unless there is a very good reason not to do it.

Commented On 30 Jun 2022 at 09:12:35

Vrurg

Fix a copy-paste erratum

Copied over from inode

Pushed On 30 Jun 2022 at 08:57:02

Vrurg

Add method 'inode'

The syscall is already supported by nqp, no extra efforts needed.

Pushed On 30 Jun 2022 at 08:43:54

Vrurg

Add IO::Path dev and devtype methods

dev returns stat(2) st_dev field (nqp::const::STAT_PLATFORM_DEV). devtype returns stat(2) st_rdev field (nqp::const::STAT_PLATFORM_DEVTYPE).

Pushed On 30 Jun 2022 at 08:43:54

Vrurg

Merge pull request #4974 from vrurg/io-path-inode

Add method 'inode'

Pushed On 30 Jun 2022 at 08:43:54
Pull Request

Vrurg

Add method 'inode'

Created On 30 Jun 2022 at 08:43:53

Vrurg

Consider Positional/Associative type parameters in optional defaults

We need to copy type parameters for this; thankfully, the type of the @/% must be of Positional/Associative, whose parameters correspond to Array/Hash's, so methods for these are already defined.

Allows the following signatures to produce a typechecking error for $a instead of @l or %h:

:(Str :@l, Str :$a) :(Str :%h, Str :$a) :(Str @l?, Str :$a) :(Str %h?, Str :$a)

Preserving:

:(:@l, Str :$a) :(:%h, Str :$a)

Pushed On 30 Jun 2022 at 08:43:08

Vrurg

Merge pull request #4648 from Kaiepi/optional-collections

Consider Positional/Associative type parameters in optional defaults

Pushed On 30 Jun 2022 at 08:43:08
Pull Request

Vrurg

Consider Positional/Associative type parameters in optional defaults

Created On 30 Jun 2022 at 08:43:05

Djerius

started

Started On 30 Jun 2022 at 07:15:27
Issue Comment

Vrurg

Add method 'inode'

The syscall is already supported by nqp, no extra efforts needed.

Forked On 29 Jun 2022 at 11:38:02

Vrurg

@Xliff I have certain doubts about the naming of dev method. Would like to give it another day to mull about, perhaps.

Commented On 29 Jun 2022 at 11:38:02