Re: Perl 6 Advent calendar open for contributions

2018-11-16 Thread Simon Proctor
Can I just say on this. I did one last year,

I don't think I'd been doing anything with Perl6 the year before.

You don't have to be some kind of super guru or anything you just need to
have something *you* like about the language or it's uses that you think
others might find interesting.

The only thing you have to fear is fear itself and all that. ;)

Go on. Give it a go.



On Fri, 16 Nov 2018 at 06:27, JJ Merelo  wrote:

> Do you have something to say with/about Perl 6? Add your name (and then
> write the article) to the Perl 6 Advent Calendar schedule!
> https://github.com/perl6/mu/blob/master/misc/perl6advent-2018/schedule
>
> ... Please!
>
> Cheers
>
> --
> JJ
>


-- 
Simon Proctor
Cognoscite aliquid novum cotidie

http://www.khanate.co.uk/


Re: More efficient of two coding styles?

2018-11-16 Thread Brad Gilbert
I don't know if either one has had any specific optimizations applied to it.

I would go for the multi-dispatch form if there is no overlap of functionality.
I think this would have a higher likelihood of getting the subroutine
inlined, because the code will be smaller.

If you really care that much more about performance than code
readability, then you should benchmark both.
You should run the benchmark on every release as it may change with
new optimizations.

I would personally just go with whatever is easier to understand.
On Thu, Nov 15, 2018 at 9:55 PM Richard Hainsworth
 wrote:
>
> Suppose I have a sub called C that runs different code depending
> on the content of an argument.
>
> There are two styles in Perl 6 to code this and my question is whether
> one is more efficient (speed/memory) than the other.
>
> In this example, one relies on multiple dispatch, while the other an
> explicit control statement.
>
> Putting aside clarity considerations, is there any performance reason to
> prefer one style over another?
>
> Style 1
>
> multi sub handle( $node WHERE *.name ~~ 'one' ) {
>
>  'this is a wonderful sub'
>
> }
>
> multi sub handle( $node WHERE *.name ~~ 'two' ) {
>
> 'twas brillig and the slivy toves did gyre'
>
> }
>
>
> Style 2
>
> sub handle ( $node ) {
>
>  given $node.name {
>
>  when 'one' { 'this is a wonderful sub' }
>
>  when 'two' { 'twas brillig and the slivy toves did gyre' }
>
>  }
>
> }