Re: [perl #76442] [BUG} say ?1..2 # prints ones indefinitively

2010-07-12 Thread Carl Mäsak
cognominal stef ():
 Currently the Range creator method does not coerce its parameters.
 I think Range should be a role so as to impose some constraint.
 I think  Bool..2  should fail.

For what it's worth, I disagree. I think Bool..2 should be equivalent
to 0..2 (since Bool is a type object, which numifies to 0). Possibly
with a warning, since something undefined is being numified.

Patrick pointed out on #perl6 that infix:.. cannot be meant to
numify by default, because then 'a'..'z' wouldn't work. But either of
these options would still be viable:

* If the rhs is Numeric, numify the lhs.
* If either the lhs or the rhs is Numeric, numify the other one.

I haven't come up with a use case to show that one of these options is
better than the other. The first is a bit reminiscent of
smartmatching; the second is more symmetric.

I don't think Range should be a role. I don't have any rational
argument, just the feeling that it's something of a premature type
restriction.

// Carl


Re: r31627 -[S32/Temporal] Changed to use a different way of specifying time zones, which is hopefully saner than my last proposal.

2010-07-12 Thread Jonathan Scott Duff
On Sun, Jul 11, 2010 at 12:56 PM, pugs-comm...@feather.perl6.nl wrote:

 Author: Kodi
 Date: 2010-07-11 19:56:33 +0200 (Sun, 11 Jul 2010)
 New Revision: 31627

 Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
 Log:
 [S32/Temporal] Changed to use a different way of specifying time zones,
 which is hopefully saner than my last proposal.

 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
 ===
 --- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-11 17:09:44
 UTC (rev 31626)
 +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-11 17:56:33
 UTC (rev 31627)
 @@ -15,8 +15,8 @@

 Created: 19 Mar 2009

 -Last Modified: 8 Apr 2010
 -Version: 7
 +Last Modified: 11 July 2010
 +Version: 8

  The document is a draft.

 @@ -88,11 +88,12 @@
  All four of the aforementioned forms of Cnew accept two additional named
  arguments. C:formatter is a callable object that takes a CDateTime and
  returns a string. The default formatter creates an ISO 8601 timestamp (see
 -below). C:timezone is a callable object that takes a CDateTime and
 -returns a two-element list giving the difference from UTC in (possibly
 both
 -negative, but not of opposite signs) hours and minutes. Alternatively,
 -C:timezone can be a two-element list, which is interpreted as a static
 -offset from UTC. The default time zone is C(0, 0) (i.e., UTC).
 +below). C:timezone is a callable object that takes a CDateTime to
 +convert and a CBool that specifies the direction of the conversion: to
 +UTC if true, from UTC if false.


Perhaps it's just me, but a boolean value to specify the direction of
conversion seems wrong-ish.  An enum with two values TO_UTC and FROM_UTC
would be a little more self-documenting.


-Scott


Re: r31627 -[S32/Temporal] Changed to use a different way of specifying time zones, which is hopefully saner than my last proposal.

2010-07-12 Thread Carl Mäsak
Scott ():
 Perhaps it's just me, but a boolean value to specify the direction of
 conversion seems wrong-ish.

It's not just you. :)

// Carl


Re: r31630 -S02 : add initial formats for Blob (or Buf) literals

2010-07-12 Thread yary
On Sun, Jul 11, 2010 at 6:11 PM, Darren Duncan dar...@darrenduncan.net wrote:
...

 There is also still the need to cover something that looks like a list of
 integers, for the general case of a Blob/Buf literal, and yet it should have
 an appearance more like that of a scalar/number/string/etc than of an
 array/etc.

 Any thoughts on this?

We could allow separator characters within the literal, such as white
space plus [[,.;:]] - and/or allow adjacent Blobs to concatenate

0b'0:01;0
   1110
   1, 00,
   0:10' 0o'52, 35, 04, 37, 6' 0x'A7.0.5E'
# 0010111010001010101001110100010001110101001110100
# OR in octal 27212516421772470136
# OR in hex 5D154E88FEA705E
# OR in decimal 419209598145818718


r31645 -[S04] try to nail down CATCH exit semantics a bit more water-tightly

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-12 21:52:08 +0200 (Mon, 12 Jul 2010)
New Revision: 31645

Modified:
   docs/Perl6/Spec/S04-control.pod
Log:
[S04] try to nail down CATCH exit semantics a bit more water-tightly


Modified: docs/Perl6/Spec/S04-control.pod
===
--- docs/Perl6/Spec/S04-control.pod 2010-07-12 17:51:44 UTC (rev 31644)
+++ docs/Perl6/Spec/S04-control.pod 2010-07-12 19:52:08 UTC (rev 31645)
@@ -13,8 +13,8 @@
 
 Created: 19 Aug 2004
 
-Last Modified: 9 Jul 2010
-Version: 100
+Last Modified: 12 Jul 2010
+Version: 101
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -986,6 +986,25 @@
 it treats code inside a Cdefault block differently from code that's after
 all the Cwhen blocks but not in a Cdefault block.
 
+More specifically, when you write:
+
+CATCH {
+when Mumble {...}
+default {...}
+}
+
+you're really getting something more like:
+
+CATCH {
+when Mumble {...}
+default {...}
+
+leave(Failure);
+
+KEEP (die(Pending exceptions not handled in $!) unless 
all($!.pending».handled); $!.handled = 1);
+UNDO die $!;
+}
+
 A CCATCH block sees the lexical scope in which it was defined, but
 its caller is the dynamic location that threw the exception.  That is,
 the stack is not unwound until some exception handler chooses to



r31649 -[S02] typo for jnthn++

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 01:50:39 +0200 (Tue, 13 Jul 2010)
New Revision: 31649

Modified:
   docs/Perl6/Spec/S02-bits.pod
Log:
[S02] typo for jnthn++


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2010-07-12 21:25:25 UTC (rev 31648)
+++ docs/Perl6/Spec/S02-bits.pod2010-07-12 23:50:39 UTC (rev 31649)
@@ -4598,7 +4598,7 @@
 statement_mod_loop:symfor.say for 1..10
 statement_prefix:symgather   gather for @foo { .take }
 term:sym!!!  $x = { !!! }
-trait_does:symdoes   my $x does Freezable
+trait_mod:symdoesmy $x does Freezable
 twigil:sym?  $?LINE
 type_declarator:symsubsetsubset Nybble of Int where 
^16
 



r31650 -[S06] add .args to what a context can return

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 01:51:27 +0200 (Tue, 13 Jul 2010)
New Revision: 31650

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] add .args to what a context can return


Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2010-07-12 23:50:39 UTC (rev 31649)
+++ docs/Perl6/Spec/S06-routines.pod2010-07-12 23:51:27 UTC (rev 31650)
@@ -2469,6 +2469,7 @@
 .line
 .my
 .hints
+.args
 
 The C.callframe and C.caller methods work the same as the functions
 except that they are relative to the frame supplied as invocant.



r31652 -[Temporal] time is now a pseudo-constant like now, rand, etc

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 02:06:01 +0200 (Tue, 13 Jul 2010)
New Revision: 31652

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[Temporal] time is now a pseudo-constant like now, rand, etc


Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-12 23:59:37 UTC 
(rev 31651)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-13 00:06:01 UTC 
(rev 31652)
@@ -15,8 +15,8 @@
 
 Created: 19 Mar 2009
 
-Last Modified: 11 July 2010
-Version: 8
+Last Modified: 12 Jul 2010
+Version: 9
 
 The document is a draft.
 
@@ -57,6 +57,10 @@
 
 Returns the current POSIX time. Use the Cnow function for an
 epoch-agnostic measure of atomic seconds (i.e., an CInstant).
+Note that both Ctime and Cnow are not functions, but terms
+of the pseudo-constant variety; as such they never take an argument.
+Saying Ctime() doesn't work unless you happen to have a function
+of that name defined.
 
 =head1 CDateTime
 



r31654 -[S06] defined callsame/nextsame in terms of callwith/nextwith and callframe

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 02:13:42 +0200 (Tue, 13 Jul 2010)
New Revision: 31654

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] defined callsame/nextsame in terms of callwith/nextwith and callframe


Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2010-07-13 00:06:32 UTC (rev 31653)
+++ docs/Perl6/Spec/S06-routines.pod2010-07-13 00:13:42 UTC (rev 31654)
@@ -16,8 +16,8 @@
 
 Created: 21 Mar 2003
 
-Last Modified: 10 Jul 2010
-Version: 140
+Last Modified: 12 Jul 2010
+Version: 141
 
 This document summarizes Apocalypse 6, which covers subroutines and the
 new type system.
@@ -2663,7 +2663,11 @@
 The Ccallwith function lets you pass your own arguments to the wrapped
 function.  The Ccallsame function takes no argument; it
 implicitly passes the original argument list through unchanged.
+The Ccallsame and Cnextsame functions are really short for:
 
+callwith( |callframe(Routine).args )
+nextwith( |callframe(Routine).args )
+
 The call to C.wrap replaces the original CRoutine's Cdo property with 
the CCallable
 argument, and arranges that any call to Ccallsame, Ccallwith,
 Cnextsame or Cnextwith invokes the previous version of the



r31655 -[S02] revise blob literals a bit

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 02:44:10 +0200 (Tue, 13 Jul 2010)
New Revision: 31655

Modified:
   docs/Perl6/Spec/S02-bits.pod
Log:
[S02] revise blob literals a bit


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2010-07-13 00:13:42 UTC (rev 31654)
+++ docs/Perl6/Spec/S02-bits.pod2010-07-13 00:44:10 UTC (rev 31655)
@@ -1350,6 +1350,7 @@
 
 blob1   Blob[bit], a bit string
 blob2   Blob[uint2], a DNA sequence?
+blob3   Blob[Uint[3]], an octal string
 blob4   Blob[uint4], a hex string
 blob8   Blob[uint8], a byte string
 blob16  Blob[uint16]
@@ -3189,16 +3190,14 @@
 
 =item *
 
-Blob literals look similar to integer literals with radix markers, but are
-distinct in their details.  A Blob literal has 1 format with 3 radix
-options:
+CBlob literals look similar to integer literals with radix markers, but use
+curlies instead of angles:
 
-0b00101110100010  base 2, 1 bit per column
-0o523504376   base 8, 3 bits per column
-0xA705E   base 16, 4 bits per column
+:2{0010_1110_1000_10}   a blob1, base 2, 1 bit per column
+:8{5235 0437 6} a blob3, 3 bits per column
+:16{A705E}  a blob4, 4 bits per column
 
-TODO:  Expand this for more generality.  Meanwhile, this existing
-definition covers the common cases of specifying in bits and hexits.
+Whitespace and underscores are allowed but ignored.
 
 =item *
 



r31656 -[S12] define more forced actions on enum values

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 02:55:37 +0200 (Tue, 13 Jul 2010)
New Revision: 31656

Modified:
   docs/Perl6/Spec/S12-objects.pod
Log:
[S12] define more forced actions on enum values


Modified: docs/Perl6/Spec/S12-objects.pod
===
--- docs/Perl6/Spec/S12-objects.pod 2010-07-13 00:44:10 UTC (rev 31655)
+++ docs/Perl6/Spec/S12-objects.pod 2010-07-13 00:55:37 UTC (rev 31656)
@@ -13,8 +13,8 @@
 
 Created: 27 Oct 2004
 
-Last Modified: 11 Jul 2010
-Version: 106
+Last Modified: 12 Jul 2010
+Version: 107
 
 =head1 Overview
 
@@ -1693,9 +1693,16 @@
 
 Fri.WHAT# Day, not Int.
 +Fri# 5
+Fri.Numeric # 5
 Fri ~~ Int  # True, because derived from Int
 Fri.perl# 'Day::Fri'
+~Fri# 'Fri'
+Fri.Stringy # 'Fri'
+Fri.Str # 'Day::Fri' (used by say/print)
 Fri.key # 'Fri'
+Fri.value   # 5
+Fri.pair# :Fri(5)
+Fri.kv  # 'Fri', 5
 Fri.defined # True
 
 Other than that, number valued enums act just like numbers, while



r31657 -add 2-bits/col blob example

2010-07-12 Thread pugs-commits
Author: Darren_Duncan
Date: 2010-07-13 02:58:57 +0200 (Tue, 13 Jul 2010)
New Revision: 31657

Modified:
   docs/Perl6/Spec/S02-bits.pod
Log:
add 2-bits/col blob example

Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2010-07-13 00:55:37 UTC (rev 31656)
+++ docs/Perl6/Spec/S02-bits.pod2010-07-13 00:58:57 UTC (rev 31657)
@@ -3194,6 +3194,7 @@
 curlies instead of angles:
 
 :2{0010_1110_1000_10}   a blob1, base 2, 1 bit per column
+:4{}a blob2, 2 bits per column
 :8{5235 0437 6} a blob3, 3 bits per column
 :16{A705E}  a blob4, 4 bits per column
 



r31659 -[S02] s/Uint/uint/ for speculative native role

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 03:36:05 +0200 (Tue, 13 Jul 2010)
New Revision: 31659

Modified:
   docs/Perl6/Spec/S02-bits.pod
Log:
[S02] s/Uint/uint/ for speculative native role


Modified: docs/Perl6/Spec/S02-bits.pod
===
--- docs/Perl6/Spec/S02-bits.pod2010-07-13 01:08:45 UTC (rev 31658)
+++ docs/Perl6/Spec/S02-bits.pod2010-07-13 01:36:05 UTC (rev 31659)
@@ -1350,7 +1350,7 @@
 
 blob1   Blob[bit], a bit string
 blob2   Blob[uint2], a DNA sequence?
-blob3   Blob[Uint[3]], an octal string
+blob3   Blob[uint[3]], an octal string
 blob4   Blob[uint4], a hex string
 blob8   Blob[uint8], a byte string
 blob16  Blob[uint16]



r31660 -[S32] revert Ctime to POSIX integer seconds; don't try to do Cnow's job

2010-07-12 Thread pugs-commits
Author: lwall
Date: 2010-07-13 03:36:39 +0200 (Tue, 13 Jul 2010)
New Revision: 31660

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32] revert Ctime to POSIX integer seconds; don't try to do Cnow's job


Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-13 01:36:05 UTC 
(rev 31659)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-13 01:36:39 UTC 
(rev 31660)
@@ -16,7 +16,7 @@
 Created: 19 Mar 2009
 
 Last Modified: 12 Jul 2010
-Version: 9
+Version: 10
 
 The document is a draft.
 
@@ -50,12 +50,14 @@
 
 Note that in this document, the term POSIX time means the number of
 seconds since midnight UTC of 1 January 1970, not counting leap seconds.
-This is the same as the output of the ISO C Ctime function except that it
-also includes a fractional part.
+This is the same as the output of the ISO C Ctime function.
+Unlike in Perl 5, Ctime does not return fractional seconds, since CPOSIX
+does not define the concept during leap seconds.  You want
+to use Cnow for that instead.
 
 =head1 Ctime
 
-Returns the current POSIX time. Use the Cnow function for an
+Returns the current POSIX time as an Int. Use the Cnow function for an
 epoch-agnostic measure of atomic seconds (i.e., an CInstant).
 Note that both Ctime and Cnow are not functions, but terms
 of the pseudo-constant variety; as such they never take an argument.
@@ -70,8 +72,12 @@
 case, the argument is interpreted as POSIX time.
 
 my $now = DateTime.new(now);
-my $now = DateTime.new(time); # same thing
+my $now = DateTime.new(time); # same thing (usually)
 
+Note that a CDateTime based on Cnow can return a CDateTime
+that cannot be produced using Ctime, since Ctime doesn't know
+about leap seconds.
+
 Or you can use named arguments:
 
 my $moonlanding = DateTime.new( :year(1969), :month(7), :day(16),