r31835 -[S32/Temporal] Specified how DateTime.new(Int) should interpret ambiguous input.

2010-07-26 Thread pugs-commits
Author: Kodi
Date: 2010-07-26 15:57:17 +0200 (Mon, 26 Jul 2010)
New Revision: 31835

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32/Temporal] Specified how DateTime.new(Int) should interpret ambiguous input.

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-26 12:05:05 UTC 
(rev 31834)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-26 13:57:17 UTC 
(rev 31835)
@@ -15,8 +15,8 @@
 
 Created: 19 Mar 2009
 
-Last Modified: 24 Jul 2010
-Version: 18
+Last Modified: 26 Jul 2010
+Version: 19
 
 The document is a draft.
 
@@ -75,7 +75,10 @@
 my $now = DateTime.new(time);
 
 These two statements are equivalent except that Ctime doesn't know about
-leap seconds or fractions of seconds.
+leap seconds or fractions of seconds. Ambiguous POSIX times (such as
+915148800, which could refer to 1998-12-31T23:59:60Z or
+1999-01-01T00:00:00Z) are interpreted as non-leap seconds (so in this case,
+the result would be 1999-01-01T00:00:00Z).
 
 Or you can use named arguments:
 



Re: Suggested magic for a .. b

2010-07-26 Thread Nicholas Clark
On Tue, Jul 20, 2010 at 07:31:14PM -0400, Aaron Sherman wrote:

 2) We deny that a range whose LHS is larger than its RHS makes sense, but
 we also don't provide an easy way to construct such ranges lazily otherwise.
 This would be annoying only, but then we have declared that ranges are the
 right way to construct basic loops (e.g. for (1..1e10).reverse - $i {...}
 which is not lazy (blows up your machine) and feels awfully clunky next to
 for 1e10..1 - $i {...} which would not blow up your machine, or even make
 it break a sweat, if it worked)

There is no reason why for (1..1e10).reverse - $i {...} should *not* be lazy.

After all, Perl 5 now implements

@b = reverse sort @a

by directly sorting in reverse. Note how it's now an ex-reverse:

$ perl -MO=Concise -e '@b = reverse sort @a'
c  @ leave[1 ref] vKP/REFC -(end)
1 0 enter -2
2 ; nextstate(main 1 -e:1) v -3
b 2 aassign[t6] vKS -c
-1 ex-list lK -8
3   0 pushmark s -4
-   1 ex-reverse lK/1 --
4  0 pushmark s -5
7  @ sort lK/REV -8
- 0 ex-pushmark s -5
6 1 rv2av[t4] lK/1 -7
5# gv[*a] s -6
-1 ex-list lK -b
8   0 pushmark s -9
a   1 rv2av[t2] lKRM*/1 -b
9  # gv[*b] s -a
-e syntax OK

Likewise

foreach (reverse @a) {...}

is implemented as a reverse iterator on the array, rather than a temporary
list:

$ perl -MO=Concise -e 'foreach(reverse @a) {}'
d  @ leave[1 ref] vKP/REFC -(end)
1 0 enter -2
2 ; nextstate(main 2 -e:1) v -3
c 2 leaveloop vK/2 -d
7{ enteriter(next-9 last-c redo-8) lKS/REVERSED -a
-   0 ex-pushmark s -3
-   1 ex-list lKM -6
3  0 pushmark s -4
-  1 ex-reverse lKM/1 -6
- 0 ex-pushmark s -4
5 1 rv2av[t2] sKR/1 -6
4# gv[*a] s -5
6   # gv[*_] s -7
-1 null vK/1 -c
b   | and(other-8) vK/1 -c
a  0 iter s/REVERSED -b
-  @ lineseq vK --
8 0 stub v -9
9 0 unstack v -a
-e syntax OK



If it's part of the specification that (1..1e10).reverse is to be implemented
lazily, I'd (personally) consider that an easy enough way to construct a lazy
range.


This doesn't answer any of your other questions about what ranges of
character strings should mean. I don't really have an opinion, other than
it needs to be simple enough to be teachable.

Nicholas Clark