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

$str.Num should be the same as +$str #1108

Closed
p6rt opened this issue Jun 29, 2009 · 8 comments
Closed

$str.Num should be the same as +$str #1108

p6rt opened this issue Jun 29, 2009 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Jun 29, 2009

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

Searchable as RT67050$

@p6rt
Copy link
Author

p6rt commented Jun 29, 2009

From @moritz

13​:52 < zulon> rakudo​: say "3".Num
13​:52 < p6eval> rakudo d95def​: OUTPUT«Method 'Num' not found for
invocant of class 'Str'␤»
13​:52 <@​moritz_> zulon​: that should work

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

From allbery@ece.cmu.edu

I thought unary + was scalar/item? context in perl6, not numify.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@​kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery@​ece.cmu.edu
electrical and computer engineering, carnegie mellon university KF8NH

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

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

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

From @masak

On Tue Jun 30 01​:56​:39 2009, allbery@​ece.cmu.edu wrote​:

I thought unary + was scalar/item? context in perl6, not numify.

When in doubt, check the spec. :)

S03 (])​:
] Unlike in Perl 5, where + is a no-op, this operator coerces to
] numeric context in Perl 6.

So prefix​:<~> stringifies, prefix​:<+> numifies, and prefix<?> boolifies.
There's some kind of nice symmetry to that, isn't there?

@p6rt
Copy link
Author

p6rt commented Jun 30, 2009

From @markjreed

On Tue, Jun 30, 2009 at 4​:55 AM, Brandon S. Allbery
KF8NH<allbery@​ece.cmu.edu> wrote​:

I thought unary + was scalar/item? context in perl6, not numify.

 + is numeric context - which is one of several subtypes of item
context. Generic item context is item(); + numifies; ? boolifies; ~
stringifies.

I'm guessing you saw + used to get the length of an array, and that's
where you got that it's equivalent to P5 scalar().

--
Mark J. Reed <markjreed@​gmail.com>

@p6rt
Copy link
Author

p6rt commented Jul 21, 2009

From tann@gmx.com

rt-67050.patch
diff --git a/src/setting/Str.pm b/src/setting/Str.pm
index 636e264..4878a5e 100644
--- a/src/setting/Str.pm
+++ b/src/setting/Str.pm
@@ -2,4 +2,8 @@ class Str is also {
     method encode($encoding = 'UTF-8', $nf = '') {
         return Buf.new();
     }
+
+    method Num() {
+        return +self;
+    }
 }

@p6rt
Copy link
Author

p6rt commented Apr 23, 2010

From @bbkr

[18​:59] <bbkr> rakudo​: say "3".Num; #
http://rt.perl.org/rt3/Ticket/Display.html?id=67050 also solved?
[18​:59] <p6eval> rakudo 6783b5​: OUTPUT«3␤»
[19​:00] <moritz_> bbkr​: yes. And sufficiently tested already
[19​:01] <moritz_> rakudo​: say "3".Numeric # according to latest spec
[19​:01] <p6eval> rakudo 6783b5​: OUTPUT«3␤»
[19​:01] <bbkr> rakudo​: say (+"3").WHAT
[19​:01] <p6eval> rakudo 6783b5​: OUTPUT«Num()␤»

@p6rt
Copy link
Author

p6rt commented Apr 23, 2010

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

@p6rt p6rt closed this as completed Apr 23, 2010
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