Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thank you for the detailed answer. It indeed makes the cause of the problem clear.

For me, it's more natural to write a floating point constant one as 1.0, however, that doesn't work. And this won't even run:

time ./perl6 -e 'my $s; for 1..10000 {$s+=1./$_**2};say $s' ===SORRY!=== Unable to parse blockoid, couldn't find final '}' at line 2

I've also tried to explicitly declare the loop variable as a floating point:

./perl6 -e 'my $s;my Num $i;for 1..10000 -> $i {$s+=1/$i**2};say $s'

This has no effect, as can be seen from the following:

./perl6 -e 'my Num $s;my Num $i;for 1..10000 -> $i {$s+=1/$i**2};say $ +s' Type check failed in assignment to '$s'; expected 'Num' but got 'Rat' in method reify at src/gen/CORE.setting:4471 in method reify at src/gen/CORE.setting:4376 in method reify at src/gen/CORE.setting:4376 in method gimme at src/gen/CORE.setting:4740 in method eager at src/gen/CORE.setting:4715 in method eager at src/gen/CORE.setting:1028 in sub eager at src/gen/CORE.setting:5000

Does this mean that even though I declare $i as a Num, it's still an integer when used as a loop variable? Is it because the .. operator supplies integers?

P.S. I'm sad to see that perlmonks is slowly becoming more like reddit, where problems are met with rancorousness instead of being discussed on a technical level.

I admit that I posed the original question in a slightly more trollish way than necessary, and I apologize for the inconvenience I might have created. I didn't intend to denigrate the effort of the Perl 6 developers - an effort which is nothing short of heroic.

However, I do think that the problems with the current state of Perl 6 go way beyond the technical level, and pretending that these problems can be treated at the mere technical level is an attitude that does more harm than good on the long term.


In reply to Re^2: Perl 6 and performance by kikuchiyo
in thread Perl 6 and performance by kikuchiyo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found