Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On Tue, May 29, 2007 at 05:29:18PM -0400, Chas Owens wrote: : Okay, obviously I have more synopsis to read, but currently Pugs says: : pugs> my $posinf = * : Inf : pugs> my $neginf = -* : -Inf : : which made me think * is Inf in scalar context. Is this a bug in Pugs then? Yes, basically. * should not be committing to a numeric type (which Inf is at heart), since we want 'a'..* to work as alphanumeric "infinity" too. And while we could maybe fudge that one to respect Inf, other uses of * require that Whatever be a completely separate, non-confusable type for multiple dispatch purposes. : Is Inf the canonical way of spelling the literal "infinity"? Yes. It's more or less the IEEE definition of infinity, though we allow Int to be +/- Inf as well as Num. However, native int cannot hold Inf, though native num can, presuming IEEE floaters are supported, which all modern hardware does. : I am patching Pugs' x and xx operators to handle infinity now. The : behavior after the patch is : pugs> "a" x 5 : "a" : pugs> "a" x 0 : "" : pugs> "a" x -5 : "" : pugs> "a" x Inf : Internal error while running expression: : Infinite replications would exahust memory : pugs> "a" x -Inf : "" : : Besides fixing the spelling error on exhaust and making it a real die : instead of an internal error (which I have yet to figure out how to : do), does this match up with your expectations for the replication : operators? That's how x would work. See S03 for a description of how xx works. Larry
Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On 5/29/07, Larry Wall <[EMAIL PROTECTED]> wrote: On Tue, May 29, 2007 at 04:43:20PM -0400, Chas Owens wrote: : Just an odd corner case, but :"foo" x -* : should return an empty string and :"foo" xx -* : should return an empty list, right? I'm doubt &prefix:<->:(Whatever) is defined at all, so that's probably a run-time failure unless someone defines the appropriate multi. And if the - fails it never even gets to the x or xx. The * token doesn't mean infinity. It means that the operator you feed it to has to figure out what it means. Some operators interpret * to mean infinity. But infix:<-> interprets a * on the left to mean the end of the current subscript range. And the range operator interprets * to mean either negative or positive infinity depending on whether it's on the left or the right. We don't require (or even allow) people to say -*..* as it currently stands. Larry Okay, obviously I have more synopsis to read, but currently Pugs says: pugs> my $posinf = * Inf pugs> my $neginf = -* -Inf which made me think * is Inf in scalar context. Is this a bug in Pugs then? Is Inf the canonical way of spelling the literal "infinity"? I am patching Pugs' x and xx operators to handle infinity now. The behavior after the patch is pugs> "a" x 5 "a" pugs> "a" x 0 "" pugs> "a" x -5 "" pugs> "a" x Inf Internal error while running expression: Infinite replications would exahust memory pugs> "a" x -Inf "" Besides fixing the spelling error on exhaust and making it a real die instead of an internal error (which I have yet to figure out how to do), does this match up with your expectations for the replication operators?
Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On Tue, May 29, 2007 at 04:43:20PM -0400, Chas Owens wrote: : Just an odd corner case, but :"foo" x -* : should return an empty string and :"foo" xx -* : should return an empty list, right? I'm doubt &prefix:<->:(Whatever) is defined at all, so that's probably a run-time failure unless someone defines the appropriate multi. And if the - fails it never even gets to the x or xx. The * token doesn't mean infinity. It means that the operator you feed it to has to figure out what it means. Some operators interpret * to mean infinity. But infix:<-> interprets a * on the left to mean the end of the current subscript range. And the range operator interprets * to mean either negative or positive infinity depending on whether it's on the left or the right. We don't require (or even allow) people to say -*..* as it currently stands. Larry
Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On 5/29/07, Larry Wall <[EMAIL PROTECTED]> wrote: On Tue, May 29, 2007 at 04:05:39PM -0400, Chas Owens wrote: : On 5/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: : snip : >+If the count is less than 1, returns the null string. : >+The count may not be C<*> because Perl 6 does not support : >+infinite strings. (At least, not yet...) : snip : : Does "may not be c<*>" mean that the compiler should throw a fatal : error if it sees it or that the program will hang because it is the : programmer's fault (similar to "while 1 {}") . The compiler is generally allowed to complain about anything it knows must fail at runtime, and since scalars default to eager, this will certainly run out of memory at runtime. Larry Just an odd corner case, but "foo" x -* should return an empty string and "foo" xx -* should return an empty list, right?
Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On Tue, May 29, 2007 at 04:05:39PM -0400, Chas Owens wrote: : On 5/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: : snip : >+If the count is less than 1, returns the null string. : >+The count may not be C<*> because Perl 6 does not support : >+infinite strings. (At least, not yet...) : snip : : Does "may not be c<*>" mean that the compiler should throw a fatal : error if it sees it or that the program will hang because it is the : programmer's fault (similar to "while 1 {}") . The compiler is generally allowed to complain about anything it knows must fail at runtime, and since scalars default to eager, this will certainly run out of memory at runtime. Larry
Re: [svn:perl6-synopsis] r14405 - doc/trunk/design/syn
On 5/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: snip +If the count is less than 1, returns the null string. +The count may not be C<*> because Perl 6 does not support +infinite strings. (At least, not yet...) snip Does "may not be c<*>" mean that the compiler should throw a fatal error if it sees it or that the program will hang because it is the programmer's fault (similar to "while 1 {}") .
[svn:perl6-synopsis] r14405 - doc/trunk/design/syn
Author: larry Date: Tue May 29 11:14:43 2007 New Revision: 14405 Modified: doc/trunk/design/syn/S03.pod Log: Clarification of x and xx semantics requested by chas.owens++ Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podTue May 29 11:14:43 2007 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 26 Apr 2007 + Last Modified: 29 May 2007 Number: 3 - Version: 114 + Version: 115 =head1 Overview @@ -545,13 +545,32 @@ infix:, string replication -x +$string x $count + +Evaluates the left argument in string context, replicates the resulting +string value the number of time specified by the right argument and +returns the result as a single concatenated string regardless of context. + +If the count is less than 1, returns the null string. +The count may not be C<*> because Perl 6 does not support +infinite strings. (At least, not yet...) =item * infix:, list replication -xx +@list xx $count + +Evaluates the left argument in list context, replicates the resulting +Capture value the number of time specified by the right argument and +returns the result in a context dependent fashion. If the operator +is being evaluated in ordinary list context, the operator returns a +flattened list. In C<@@> context, the operator converts each Capture +to a separate sublist and returns the list of those sublists. + +If the count is less than 1, returns the empty list, C<()>. +If the count is C<*>, returns an infinite list (lazily, since lists +are lazy by default). =item *