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

pi and e behaving strangely when used as a bareword in math #24

Closed
p6rt opened this issue Jul 28, 2007 · 12 comments
Closed

pi and e behaving strangely when used as a bareword in math #24

p6rt opened this issue Jul 28, 2007 · 12 comments

Comments

@p6rt
Copy link

p6rt commented Jul 28, 2007

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

Searchable as RT44211$

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @perlDreamer

Please try running either the pi.t or e.t tests from pugs t/builtins/math/{e,pi}.t.

When used in an equation like this​:

pi + 3

parrot returns this error​:

too few arguments passed (1) - 2 params expected
current instr.​: 'parrot;Perl6​::Compiler;main' pc 138 (perl6.pir​:98)

pi and e don't take any arguments, so maybe it is '+' complaining?

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @pmichaud

On Fri, Jul 27, 2007 at 09​:13​:42PM -0700, Colin Kuskie wrote​:

Please try running either the pi.t or e.t tests from
pugs t/builtins/math/{e,pi}.t.

When used in an equation like this​:
pi + 3
parrot returns this error​:

too few arguments passed (1) - 2 params expected
current instr.​: 'parrot;Perl6​::Compiler;main' pc 138 (perl6.pir​:98)

pi and e don't take any arguments, so maybe it is '+' complaining?

Out of curiosity, where are 'pi' and 'e' defined (e.g., in
the Synopses or other specs)? Do these even belong in the
test suite?

Also, I'm looking at the STD.pm grammar, and I don't quite see how
or where it's handling parsing of nullary functions.

Pm

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

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

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @perlDreamer

On Saturday 28 July 2007, Patrick R. Michaud wrote​:

Out of curiosity, where are 'pi' and 'e' defined (e.g., in
the Synopses or other specs)? Do these even belong in the
test suite?

I originally came across pi in src/builtins/math.pir pi and e
are both defined in there. pi is the trig.t test from pugs.

It's mentioned directly in older versions of S29​:

http://www.rodadams.net/Perl/S29.html

In today's S29, pi is mentioned as part of the Num role. e
isn't in there at all.

Colin

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @moritz

Patrick R. Michaud wrote​:

On Fri, Jul 27, 2007 at 09​:13​:42PM -0700, Colin Kuskie wrote​:

Please try running either the pi.t or e.t tests from
pugs t/builtins/math/{e,pi}.t.

When used in an equation like this​:
pi + 3
parrot returns this error​:

too few arguments passed (1) - 2 params expected
current instr.​: 'parrot;Perl6​::Compiler;main' pc 138 (perl6.pir​:98)

pi and e don't take any arguments, so maybe it is '+' complaining?

Out of curiosity, where are 'pi' and 'e' defined (e.g., in
the Synopses or other specs)? Do these even belong in the
test suite?

S29, section "Num"​:

Num provides a number of constants in addition to the basic mathematical
functions. To get these constants, you must request them​:

use Num :constants;

or use the full name, e.g. Num​::pi.

HTH,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @pmichaud

On Sat, Jul 28, 2007 at 01​:48​:13PM -0500, Patrick R. Michaud wrote​:

Also, I'm looking at the STD.pm grammar, and I don't quite see how
or where it's handling parsing of nullary functions.

Actually, in thinking about this, there's likely to be a symbol
of available barewords somewhere in the parser, and the parser
will parse these as nouns/terms instead of list operators.
We currently don't have that feature in the compiler yet, but
I'll see about adding it soon.

Pm

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @perlDreamer

On Saturday 28 July 2007, Patrick R. Michaud wrote​:

On Sat, Jul 28, 2007 at 01​:48​:13PM -0500, Patrick R. Michaud wrote​:

Also, I'm looking at the STD.pm grammar, and I don't quite see how
or where it's handling parsing of nullary functions.

Actually, in thinking about this, there's likely to be a symbol
of available barewords somewhere in the parser, and the parser
will parse these as nouns/terms instead of list operators.
We currently don't have that feature in the compiler yet, but
I'll see about adding it soon.

Okay.

I'm seeing similar behavior with things like sin​:

use v6-alpha;

use Test;

plan 2;

{
  is(sin(pi()/2), 1, 'sin, parenthesized');
  my $halfPi = pi()/2;
  is(sin $halfPi , 1, 'sin, bareword with a variable');
}

returns

1..2
ok 1 - is! sin, parenthesized
Null PMC access in invoke()
current instr.​: 'parrot;Perl6​::Compiler;main' pc 138 (perl6.pir​:98)

So that should fix a whole raft of semi-related bugs.

@p6rt
Copy link
Author

p6rt commented Jul 28, 2007

From @pmichaud

On Sat, Jul 28, 2007 at 01​:01​:05PM -0700, Colin Kuskie wrote​:

On Saturday 28 July 2007, Patrick R. Michaud wrote​:

Actually, in thinking about this, there's likely to be a symbol
of available barewords somewhere in the parser, and the parser
will parse these as nouns/terms instead of list operators.
We currently don't have that feature in the compiler yet, but
I'll see about adding it soon.

I'm seeing similar behavior with things like sin​:

is\(sin $halfPi , 1, 'sin, bareword with a variable'\);

Correct -- the same sort of argument applies for 1-ary functions
acting as prefix operators instead of standard functions. We just
don't have that sort of change-the-parse-based-on-function-definition
capability implemented yet.

Pm

@p6rt
Copy link
Author

p6rt commented Aug 12, 2007

From @moritz

Patrick R. Michaud wrote​:

On Fri, Jul 27, 2007 at 09​:13​:42PM -0700, Colin Kuskie wrote​:

Please try running either the pi.t or e.t tests from
pugs t/builtins/math/{e,pi}.t.

When used in an equation like this​:
pi + 3
parrot returns this error​:

too few arguments passed (1) - 2 params expected
current instr.​: 'parrot;Perl6​::Compiler;main' pc 138 (perl6.pir​:98)

pi and e don't take any arguments, so maybe it is '+' complaining?

Out of curiosity, where are 'pi' and 'e' defined (e.g., in
the Synopses or other specs)? Do these even belong in the
test suite?

S29, section "Num"​:

Num provides a number of constants in addition to the basic mathematical
functions. To get these constants, you must request them​:

use Num :constants;

or use the full name, e.g. Num​::pi.

HTH,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Aug 12, 2007

From @perlDreamer

On Saturday 28 July 2007, Patrick R. Michaud wrote​:

Out of curiosity, where are 'pi' and 'e' defined (e.g., in
the Synopses or other specs)? Do these even belong in the
test suite?

I originally came across pi in src/builtins/math.pir pi and e
are both defined in there. pi is the trig.t test from pugs.

It's mentioned directly in older versions of S29​:

http://www.rodadams.net/Perl/S29.html

In today's S29, pi is mentioned as part of the Num role. e
isn't in there at all.

Colin

@p6rt
Copy link
Author

p6rt commented Jun 26, 2008

From @pmichaud

pi() is fixed as of r28699. The 'e' constant appears to be no longer
part of the spec.

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