Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^4: Perl 6 and performance

by kikuchiyo (Monk)
on Feb 09, 2012 at 21:00 UTC ( #952847=note: print w/replies, xml ) Need Help??

in reply to Re^3: Perl 6 and performance
in thread Perl 6 and performance

To clarify things, 1. is not a valid number in Perl 6. 1.0 is a Rat, 1e0 or 1.0e0 are Num.

This is news to me. In most languages 1.0 is the syntax used to denote floating point constants.

...I am aware that Perl 6 is not most languages, but for people coming from those languages, this feature will be somewhat surprising.

A way to fix that is writing -> Num $i { }, but then you get a type check failure because 1..1000 indeed produces Ints, not Nums. So either you coerce to Num somewhere (for example $i.Num ** 2), or you write the range as 1e0 .. 1e3.
Excellent. However:
./perl6 -e 'my Num $s;for 1e0..1e3 -> Num $i {$s+=1e0/$i**2};say $s' Nominal type check failed for parameter '$i'; expected Num but got Int + instead
User feedback like yours is what we need, and one of the reasons for making the star releases in the first place.

Glad to have been of help then. By the way, the performance increase is noticeable in the new release, and I guess it will only get better, and the effect of further optimizations will be compounded, as Rakudo itself is mostly written in Perl 6.

About 1.6 orders of magnitude of performance increase down, 2.6 to get to the level of Perl 5, or 1.6 to overtake Ruby. :)

Replies are listed 'Best First'.
Re^5: Perl 6 and performance
by moritz (Cardinal) on Feb 10, 2012 at 05:52 UTC
    ./perl6 -e 'my Num $s;for 1e0..1e3 -> Num $i {$s+=1e0/$i**2};say $s' Nominal type check failed for parameter '$i'; expected Num but got Int + instead

    Oops, that's a bug in Rakudo. I've opened a ticket for it. Now that's the second piece of valuable feedback you've given us. Thanks again.

    Update: I have fixed this bug, so the code with -> Num $i { ... } will work in the next release.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952847]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2017-09-25 19:50 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (288 votes). Check out past polls.