Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rand gets "invoke() not implemented in class 'Float' " - Revision: 28671 #145

Closed
p6rt opened this issue Jun 23, 2008 · 10 comments
Closed

rand gets "invoke() not implemented in class 'Float' " - Revision: 28671 #145

p6rt opened this issue Jun 23, 2008 · 10 comments

Comments

@p6rt
Copy link

p6rt commented Jun 23, 2008

Migrated from rt.perl.org#56266 (status was 'resolved')

Searchable as RT56266$

@p6rt
Copy link
Author

p6rt commented Jun 23, 2008

From Andy_Bach@wiwb.uscourts.gov

This was working​:
$ ./perl6 -e 'say rand(3)'
invoke() not implemented in class 'Float'
current instr.​: '_block11' pc 41 (EVAL_13​:18)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 806
(src/PCT/HLLCompiler.pir​:481)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 12318 (perl6.pir​:174)

However,
$ ./perl6 -e 'say rand()'
0.944425

works. This fail the same way on at least 2 linux boxes
This is perl, v5.8.3 built for i586-linux-thread-multi
(with 1 registered patch, see perl -V for more detail)

for revision​: 28671

uname -a
Linux DCLOES3A 2.6.5-7.286-smp #​1 SMP Thu May 31 10​:12​:58 UTC 2007 i686
i686 i386 GNU/Linux

a


Andy Bach
Systems Mangler
Internet​: andy_bach@​wiwb.uscourts.gov
Voice​: (608) 261-5738 Fax​: 264-5932

The name "grep" is from the common "ed" (pre-visual "vi") command​:
g/re/p i.e. g(lobal-search)/r(egular) e(xpression)/p(rint)

@p6rt
Copy link
Author

p6rt commented Jun 24, 2008

From @pmichaud

On Mon Jun 23 13​:32​:47 2008, Andy_Bach@​wiwb.uscourts.gov wrote​:

This was working​:
$ ./perl6 -e 'say rand(3)'
invoke() not implemented in class 'Float'
current instr.​: '_block11' pc 41 (EVAL_13​:18)

According to S29​:295, the rand() function no longer takes any arguments​:

: =item rand
:
: our Num method rand ( Num $x​: )
: our Num term​:<rand>
:
: Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is
: theoretically possible, while C<$x> is not. The C<rand> function
: is 0-ary and always produces a number from C<0..^1>. In any case,
: for picking a random integer you probably want to use something like
: C<(1..6).pick> instead.

I agree that Rakudo needs to give a better error message in this case,
and will fix that shortly.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 24, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 24, 2008

From @pmichaud

[re-sending to cc​: perl6-compiler@​perl.org]

On Mon Jun 23 13​:32​:47 2008, Andy_Bach@​wiwb.uscourts.gov wrote​:

This was working​:
$ ./perl6 -e 'say rand(3)'
invoke() not implemented in class 'Float'
current instr.​: '_block11' pc 41 (EVAL_13​:18)

According to S29​:295, the rand() function no longer takes any arguments​:

: =item rand
:
: our Num method rand ( Num $x​: )
: our Num term​:<rand>
:
: Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is
: theoretically possible, while C<$x> is not. The C<rand> function
: is 0-ary and always produces a number from C<0..^1>. In any case,
: for picking a random integer you probably want to use something like
: C<(1..6).pick> instead.

I agree that Rakudo needs to give a better error message in this case,
and will fix that shortly.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 25, 2008

From Andy_Bach@wiwb.uscourts.gov

Hi

Thanks for the replies​:

: =item rand
:
: our Num method rand ( Num $x​: )
: our Num term​:<rand>
:
: Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is
: theoretically possible, while C<$x> is not. The C<rand> function
: is 0-ary and always produces a number from C<0..^1>.

Hmm, I'd've thought that meant that 'rand' takes no params and returns
0..^1 but rand( Num $x​: ) returns 0 .. ^$x but

: In any case, for picking a random integer you probably want to use
something like
: C<(1..6).pick> instead.

There's some missing methods s not yet, I guess​:

./perl6 -e 'say (1 .. 6).pick'
Method 'pick' not found for invocant of class 'Range'
current instr.​: '_block11' pc 49 (EVAL_13​:20)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 806
(src/PCT/HLLCompiler.pir​:481)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 12318 (perl6.pir​:174)

No 'pick' for Junction or any yet
./perl6 -e 'my $i = one(1 .. 6).any + 0; say $i'
Method 'any' not found for invocant of class 'Junction'

I tried a number whacks using prefix​:
./perl6 -e 'my $i = any(1 .. 6) ; say $i'
./perl6 -e 'my $i = any(1 .. 6) + 0; say $i'
./perl6 -e 'my @​arr = (1 .. 6); my $i = any(1..6); say @​arr[$i]'

but no get_string or get_integer for Junction makes them a little hard to
use. Not complaining, just a note.

Thanks.

a


Andy Bach
Systems Mangler
Internet​: andy_bach@​wiwb.uscourts.gov
Voice​: (608) 261-5738 Fax​: 264-5932

The name "grep" is from the common "ed" (pre-visual "vi") command​:
g/re/p i.e. g(lobal-search)/r(egular) e(xpression)/p(rint)

@p6rt
Copy link
Author

p6rt commented Jun 25, 2008

From @pmichaud

On Tue, Jun 24, 2008 at 02​:27​:04PM -0500, Andy_Bach@​wiwb.uscourts.gov wrote​:

: =item rand
:
: our Num method rand ( Num $x​: )
: our Num term​:<rand>
:
: Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is
: theoretically possible, while C<$x> is not. The C<rand> function
: is 0-ary and always produces a number from C<0..^1>.

Hmm, I'd've thought that meant that 'rand' takes no params and returns
0..^1 but rand( Num $x​: ) returns 0 .. ^$x but

The first rand is a method on the Num type. Since it's not specified
as "is export", it remains strictly a method and doesn't supply a
multisub form.

: In any case, for picking a random integer you probably want to use
something like
: C<(1..6).pick> instead.

There's some missing methods s not yet, I guess​:

./perl6 -e 'say (1 .. 6).pick'
Method 'pick' not found for invocant of class 'Range'

Correct, we haven't implemented .pick on Range objects yet. I'm not
sure if we should have a separate .pick method for Range, or if List
actually needs to be a role, or if there's some other role common to
List and Range that should be providing .pick and other similar
methods.

No 'pick' for Junction or any yet
./perl6 -e 'my $i = one(1 .. 6).any + 0; say $i'
Method 'any' not found for invocant of class 'Junction'

I tried a number whacks using prefix​:
./perl6 -e 'my $i = any(1 .. 6) ; say $i'
./perl6 -e 'my $i = any(1 .. 6) + 0; say $i'
./perl6 -e 'my @​arr = (1 .. 6); my $i = any(1..6); say @​arr[$i]'

but no get_string or get_integer for Junction makes them a little hard to
use. Not complaining, just a note.

get_string and get_integer on junction should autothread to their
underlying components. We may have junction autothreading
disabled at the moment in Rakudo.

In particular, C< say any(1..6) > should result in six invocations of
C<say>, one for each element in the Junction, each of those would then
invoke get_string on the elements.

Pm

@p6rt
Copy link
Author

p6rt commented Jun 25, 2008

From @pmichaud

On Wed, Jun 25, 2008 at 12​:49​:35PM -0500, Patrick R. Michaud wrote​:

On Tue, Jun 24, 2008 at 02​:27​:04PM -0500, Andy_Bach@​wiwb.uscourts.gov wrote​:

: =item rand
:
: our Num method rand ( Num $x​: )
: our Num term​:<rand>
:
: Pseudo random number in range C<< 0 ..^ $x >>. That is, C<0> is
: theoretically possible, while C<$x> is not. The C<rand> function
: is 0-ary and always produces a number from C<0..^1>.

Hmm, I'd've thought that meant that 'rand' takes no params and returns
0..^1 but rand( Num $x​: ) returns 0 .. ^$x but

The first rand is a method on the Num type. Since it's not specified
as "is export", it remains strictly a method and doesn't supply a
multisub form.
[...]
Correct, we haven't implemented .pick on Range objects yet. I'm not
sure if we should have a separate .pick method for Range, or if List
actually needs to be a role, or if there's some other role common to
List and Range that should be providing .pick and other similar
methods.

Larry++ just reminded me on #perl6 that .pick (and .rand) are now
methods on Any (see the bottom paragraph of [1]), so once Rakudo
moves its methods over to Any then things will work quite a bit
better.

Thanks!

Pm

[1] http://groups.google.com/group/perl.perl6.compiler/msg/acf1cfbb16b998cf

@p6rt
Copy link
Author

p6rt commented Jun 26, 2008

From @pmichaud

The issue with error messages from arguments to rand() is fixed in
r28699; the .pick method has been added as of r28703. If there are
other unaddressed issues in this ticket, please open new ones.

Thanks!

Pm

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jun 26, 2008

From @pmichaud

The issue with error messages from arguments to rand() is fixed in
r28699; the .pick method has been added as of r28703. If there are
other unaddressed issues in this ticket, please open new ones.

Thanks!

Pm

@p6rt
Copy link
Author

p6rt commented Jun 26, 2008

@pmichaud - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Jun 26, 2008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant