Re: More efficient of two coding styles?

2018-11-17 Thread Parrot Raiser
On 11/15/18, Richard Hainsworth wrote: > There are two styles in Perl 6 to code this and my question is whether > one is more efficient (speed/memory) than the other. > First, define efficiency. Which is cheaper, computer time or programmer time? Is whatever is being considered a constraint of

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

Re: More efficient of two coding styles?

2018-11-15 Thread Brent Laabs
I don't know the answer to your specific question -- maybe try benchmarking it? Subroutine dispatch is normally pretty fast, as are given statements. Both when and ~~ call the ACCEPTS method, just at different times in your examples. I'm not really sure if the JIT will kick in better in one case

Re: More efficient of two coding styles?

2018-11-15 Thread Richard Hainsworth
Brent, Thanks for the rapid response, but it does not really answer the intent of the question. Essentially, you said that one style provides for a silent default, the other does not. The intent of the question is about performance - as in the subject line. Perhaps the word 'style' is

Re: More efficient of two coding styles?

2018-11-15 Thread Brent Laabs
They do two different things. Style 1 will throw a dispatch error if $ node.name has a value of 'three', where Style 2 will do nothing in that case. On Thu, Nov 15, 2018 at 7:55 PM Richard Hainsworth wrote: > Suppose I have a sub called C that runs different code depending > on the content of

More efficient of two coding styles?

2018-11-15 Thread Richard Hainsworth
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