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

Reply via email to