Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #22765] Unary '+' is not symmetric to unary '-' in languages/perl6

3 views
Skip to first unread message

Sean O'Rourke

unread,
Jun 24, 2003, 9:12:15 AM6/24/03
to perl6-i...@perl.org, bugs-bi...@netlabs.develooper.com, r...@x1.develooper.com
Looks good, except that this needs to make sure an int is being
returned, e.g.

+"42" -> 42
+"forty-two" -> 0

The lazy man in me would just shove it through an int reg, but that
loses precision if we go to bignums. Though for the moment I can't
think of a better way.

/s

+# unary plus.
+sub prefix_pos {
+ my $x = shift;
+ my $tmp = $x->args->val;
+ my $res = newtmp;
+ code(<<END);
+ $res = $tmp
+END
+ return scalar_in_context($res, $x->{ctx});
+}


On Mon, 23 Jun 2003, Bernhard Schmalhofer wrote:

> # New Ticket Created by Bernhard Schmalhofer
> # Please include the string: [perl #22765]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22765 >
>
>
> Hi,
>
> when playing with the stuff in 'languages/perl6', I noticed that code like
> print( +42, "\n" );
> didn't do the right thing. 'perl6' printed '42' but forgot about the "\n".
>
> The cause seemed to me that '+' isn't set up as an unary operator in
> 'P6C/Parser.pm'.
> After adding '+' in 'Parser.pm' and in a couple of othe files, it now seems
> to behave as expected.
>
> On my Linux machine there are some other tests failing in t/compiler, but
> these seem not to be related to unary '+'.
> One of these failures is a 'inf' vs. 'Inf' issue.
>
> A patch is attached.
>
> CU, Bernhard
>
> --
> +++ GMX - Mail, Messaging & more http://www.gmx.net +++
> Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!
>
> -- attachment 1 ------------------------------------------------------
> url: http://rt.perl.org/rt2/attach/59761/44242/d4c34a/prefix_pos.patch
>
>

Leopold Toetsch

unread,
Jun 25, 2003, 9:04:55 AM6/25/03
to perl6-i...@perl.org
Bernhard Schmalhofer <bugs-...@netlabs.develooper.com> wrote:
> # New Ticket Created by Bernhard Schmalhofer
> # Please include the string: [perl #22765]
> # in the subject line of all future correspondence about this issue.
> # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=22765 >


> Hi,

> when playing with the stuff in 'languages/perl6', I noticed that code like
> print( +42, "\n" );
> didn't do the right thing. 'perl6' printed '42' but forgot about the "\n".

Applied, thanks

(This needs a --force-grammar after cvs update)

leo

0 new messages