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