r31678 -[S32/Temporal] DateTime.new(Numeric) - DateTime.new(Int), since time no longer returns fractional seconds.
Author: Kodi Date: 2010-07-14 16:02:34 +0200 (Wed, 14 Jul 2010) New Revision: 31678 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod Log: [S32/Temporal] DateTime.new(Numeric) - DateTime.new(Int), since time no longer returns fractional seconds. Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod === --- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 12:50:51 UTC (rev 31677) +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 14:02:34 UTC (rev 31678) @@ -15,8 +15,8 @@ Created: 19 Mar 2009 -Last Modified: 12 Jul 2010 -Version: 10 +Last Modified: 14 Jul 2010 +Version: 11 The document is a draft. @@ -57,7 +57,7 @@ =head1 Ctime -Returns the current POSIX time as an Int. Use the Cnow function for an +Returns the current POSIX time as an CInt. Use Cnow 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. @@ -68,15 +68,14 @@ A CDateTime object describes the time as it would appear on someone's calendar and someone's clock. You can create a CDateTime object from an -CInstant or from any object that does the CNumeric role; in the latter -case, the argument is interpreted as POSIX time. +CInstant or from an CInt; in the latter case, the argument is +interpreted as POSIX time. my $now = DateTime.new(now); -my $now = DateTime.new(time); # same thing (usually) +my $now = DateTime.new(time); -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. +These two statements are equivalent except that Ctime doesn't know about +leap seconds or fractions of seconds. Or you can use named arguments:
r31680 -[S32/Temporal] Added to Date: There are also Cweek, Cweek-year, Cweek-number, Cweekday-of-month, and Cday-of-year methods, which work just like their DateTime equivalents.
Author: Kodi Date: 2010-07-14 16:35:46 +0200 (Wed, 14 Jul 2010) New Revision: 31680 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod Log: [S32/Temporal] Added to Date: There are also Cweek, Cweek-year, Cweek-number, Cweekday-of-month, and Cday-of-year methods, which work just like their DateTime equivalents. Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod === --- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 14:35:21 UTC (rev 31679) +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 14:35:46 UTC (rev 31680) @@ -16,7 +16,7 @@ Created: 19 Mar 2009 Last Modified: 14 Jul 2010 -Version: 11 +Version: 12 The document is a draft. @@ -244,6 +244,9 @@ $d.days-in-month# 31 $d.Str # '2010-12-24' +There are also Cweek, Cweek-year, Cweek-number, Cweekday-of-month, +and Cday-of-year methods, which work just like their DateTime equivalents. + =head2 Arithmetics $d.succ # Date.new('2010-12-25')
Re: Contribution to perl 6 - week 9 Hash.pick
Hi, thank you very much for your contribution. I'm now in the middle of testing and applying it, and if all goes right, I'll push it tonight (ie in the course of a few hours). According to my tests it does exactly what it should, I only found one minor bug: {a = 1, b = 0}.pick(*) would produce a... Radu Stoica wrote: +} else { +my %copyHash = self; Changing this line to my %copyHash = @.pairs.grep({ .value != 0}); fixed the problem. I'll also fix some minor nits, like simplifying my $middle = $l + floor( ($r-$l)/2); to my $middle = floor ($r + $l) / 2 which is a tad easier to understand, and maybe a tad faster. I'll also try to remove some duplicate code, but all in all it's really a fine implementation. Thanks again! Cheers, Moritz
r31689 -[S32/Temporal] Permit days-in-month and is-leap-year on DateTimes, too.
Author: Kodi Date: 2010-07-14 23:18:42 +0200 (Wed, 14 Jul 2010) New Revision: 31689 Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod Log: [S32/Temporal] Permit days-in-month and is-leap-year on DateTimes, too. Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod === --- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 20:35:20 UTC (rev 31688) +++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-07-14 21:18:42 UTC (rev 31689) @@ -16,7 +16,7 @@ Created: 19 Mar 2009 Last Modified: 14 Jul 2010 -Version: 12 +Version: 13 The document is a draft. @@ -157,9 +157,17 @@ month, the day itself included. For example, June 9, 2003 is the second Monday of the month, and so this method returns 2 for that day. +The Cdays-in-month method returns the number of days in the current +month of the current year. So in the case of January, Cdays-in-month +always returns 31, whereas in the case of February, Cdays-in-month +returns 28 or 29 depending on the year. + The Cday-of-year method returns the day of the year, a value between 1 and 366. +The method Cis-leap-year returns a CBool, which is true if and only +if the current year is a leap year in the Gregorian calendar. + The method Cwhole-second returns the second truncated to an integer. The CDate method returns a CDate object, and is the same as @@ -232,20 +240,23 @@ =head2 Accessors -The following accessors are pretty obvious, and are defined by example only. -See the test suite for more formal definitions. +CDate objects support all of the following accessors, which work just +like their CDateTime equivalents: -my $d = Date.new('2010-12-24'); -$d.year # 2010 -$d.month# 12 -$d.day # 24 -$d.day-of-week # 5 # Friday -$d.is-leap-year # Bool::False -$d.days-in-month# 31 -$d.Str # '2010-12-24' +year +month +day +day-of-week +week +week-year +week-number +day-of-week +weekday-of-month +days-in-month +day-of-year +is-leap-year -There are also Cweek, Cweek-year, Cweek-number, Cweekday-of-month, -and Cday-of-year methods, which work just like their DateTime equivalents. +The Str method returns a string of the form '-mm-dd'. =head2 Arithmetics
Re: r31651 -[S13] try to make multisig semantics slightly more generic so sigs can do better pattern matching
On Mon, Jul 12, 2010 at 7:59 PM, pugs-comm...@feather.perl6.nl wrote: Author: lwall Date: 2010-07-13 01:59:37 +0200 (Tue, 13 Jul 2010) New Revision: 31651 Modified: docs/Perl6/Spec/S13-overloading.pod Log: [S13] try to make multisig semantics slightly more generic so sigs can do better pattern matching ... +are not required to all bind the same set of formal variable names, +nor are all parameters of a given name required to bind with the +same type. Unbound parameters will be born with an undefined value +(even if they have a default). For any parameter that occurs in +multiple signatures with non-identical nominal types, the actual +lexical variable will declared will *be* declared? -- Aaron Sherman Email or GTalk: a...@ajs.com http://www.ajs.com/~ajs
[perl #76492] [TODO] implement autovivification of invocants
# New Ticket Created by Moritz Lenz # Please include the string: [perl #76492] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76492 my %h; %hab.push: 5; say %h.perl Method 'push' not found for invocant of class '' Expected output: { ab = [5] } Cheers, Moritz
[perl #76504] make spectest results
# New Ticket Created by Greg Donald # Please include the string: [perl #76504] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76504 git rev-parse HEAD 6ab7415762a5bc6269ddd8d4dae023e6f357a429 make spectest Test Summary Report --- t/spec/S04-exception-handlers/catch.rakudo (Wstat: 0 Tests: 24 Failed: 0) TODO passed: 20-21 t/spec/S05-mass/recursive.rakudo (Wstat: 0 Tests: 20 Failed: 5) Failed tests: 1, 5, 9, 13, 17 t/spec/S05-mass/rx.rakudo(Wstat: 0 Tests: 724 Failed: 1) Failed test: 625 t/spec/S05-metasyntax/null.t (Wstat: 0 Tests: 4 Failed: 3) Failed tests: 1-3 t/spec/S10-packages/basic.rakudo (Wstat: 0 Tests: 51 Failed: 0) TODO passed: 41-42, 44, 46 t/spec/S32-temporal/DateTime.t (Wstat: 256 Tests: 47 Failed: 11) Failed tests: 14, 24, 33-38, 43, 45, 47 Non-zero exit status: 1 Parse errors: No plan found in TAP output Files=496, Tests=33420, 6073 wallclock secs (15.51 usr 3.63 sys + 5844.93 cusr 166.37 csys = 6030.44 CPU) Result: FAIL Please let me know how to provide more specific information the failures. Thanks, -- Greg Donald
[perl #76508] [BUG] Segfault on binding a variable to itself in Rakudo
# New Ticket Created by Carl Mäsak # Please include the string: [perl #76508] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76508 pmurias rakudo: my $a = 2;$a := $a; say $a p6eval rakudo c8b6cf: ( no output ) pmurias rakudo: my $a = 2;my $b; $b := $a; say $b p6eval rakudo c8b6cf: OUTPUT«2» pmurias isn't the first one a bug? masak looks like. masak unless p6eval is acting up again. moritz_ it segfaults locally * masak submits rakudobug
[perl #76510] [BUG] =:= doesn't seem to work as spec'd in Rakudo
jnthn What is pir::issame being used for? masak checking for =:= equivalence, I'd guess. jnthn That sounds wrong. jnthn =:= means references the same thingy right? masak aye. jnthn pretty sure the issame op is not what is wanted then * masak adds that to the ticket
Contribution to perl 6 - week 9 Hash.pick
Hi, Please see below the code. It does not check for integer values yet and the algorithm is based on the suggestion made in moritz's post. diff --git a/src/core/Hash.pm b/src/core/Hash.pmindex 0365dfc..b2fa0ae 100644--- a/src/core/Hash.pm+++ b/src/core/Hash.pm@@ -96,6 +96,69 @@ role Hash is EnumMap { multi method sort(by = infix:cmp) { self.pairs.sort(by) }+ + multi method pick() {+ my @weights = [\+] self.values;+ my $value = @weights[*-1].rand;+ return self.keys[0] if @weights[0] $value;+ my ($l, $r) = (0, @weights.elems-1);+ my $middle = $l + floor( ($r-$l)/2);+ while ($middle $l) {+ if @weights[$middle] $value {+ $l = $middle;+ }+ else {+ $r = $middle;+ }+ $middle = $l + floor( ($r-$l)/2);+ }+ self.keys[$r];+ }++ multi method pick($num is copy = 1, :$replace) {+ if ($num == 1) {+ my @weights = [\+] self.values;+ my $value = @weights[*-1].rand;+ return self.keys[0] if @weights[0] $value;+ my ($l, $r) = (0, @weights.elems-1);+ my $middle = $l + floor( ($r-$l)/2);+ while ($middle $l) {+ if @weights[$middle] $value {+ $l = $middle;+ }+ else {+ $r = $middle;+ }+ $middle = $l + floor( ($r-$l)/2);+ }+ return self.keys[$r];+ }++ if $replace {+ gather {+ while $num 0 {+ take self.pick();+ $num--;+ }+ }+ } else {+ my %copyHash = self;+ gather {+ while $num 0 %copyHash {+ my $picked;+ take $picked = %copyHash.pick();+ unless --%copyHash{$picked} {+ %copyHash.delete($picked);+ }+ $num--;+ }+ }+ }+ }++ multi method pick(Whatever, :$replace) {+ self.pick(Inf, :$replace);+ } }
[perl #76490] Regression in Parent{ :attributevalue } initialization
# New Ticket Created by Moritz Lenz # Please include the string: [perl #76490] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76490 In the course of the 'ng' branch, Rakudo has regressed on passing parent attributes to constructors. Tests can be found in t/spec/S12-construction/new.t
[perl #76498] [BUG] Strange error of use statement
# New Ticket Created by Hongwen Qiu # Please include the string: [perl #76498] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76498 $ perl6 -v This is Rakudo Perl 6, version Kiev-235-g6ab7415 $ cat testa.p6 use Tufte::Renderer::Standard; $ cat Tufte/Renderer/Standard.pm class Tufte::Renderer::Standard; $ perl6 testa.p6 ===SORRY!=== Confused at line 1, near \nuse Tufte $ cat testb.p6 use Tufte::Renderer::New; $ cat Tufte/Renderer/New.pm class Tufte::Renderer::New; $ perl6 testb.p6 # Nothing output. $ cat testc.p6 use Tufte::Standard; $ cat Tufte/Standard.pm class Tufte::Standard; $ perl6 testc.p6 # Nothing output. And I have tried to place the whole Tufte directory to other places, but just get the same results. So, maybe the use statement will fail on some uncertain conditions.
[perl #76500] Rakudo doesn't honor :i flag for interpolated string in regexes
# New Ticket Created by Moritz Lenz # Please include the string: [perl #76500] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76500 07:50 cbk rakudo: my $searchStr = test; my $inputStr = TEST; if ($inputStr ~~ m/:i $searchStr /) { say Search term found in string!;} else {say Not found!;} 07:50 p6eval rakudo 6ab741: OUTPUT«Not found!» 07:51 cbk rakudo: my $searchStr = TEST; my $inputStr = TEST; if ($inputStr ~~ m/:i $searchStr /) { say Search term found in string!;} else {say Not found!;} 07:51 p6eval rakudo 6ab741: OUTPUT«Search term found in string!» 07:51 * moritz_ submits rakudobug
[perl #76510] [BUG] =:= doesn't seem to work as spec'd in Rakudo
moritz_ rakudo: my ($a, $b); say $a =:= $a, $a =:= $b p6eval rakudo c8b6cf: OUTPUT«10» moritz_ rakudo: sub f($x, $y) { $x =:= $y }; my ($a, $b); say f($a, $a), f($a, $b) p6eval rakudo c8b6cf: OUTPUT«00» moritz_ bug? * masak adds that one to the ticket
Re: [perl #76486] [Bug] Multiple dispatch mechanism apparently does not descend into inner signatures
Sorry. My example was wrong. Here another one. Ca([]) executes as intended but C@t does not. I find that unintuitive. cat mmd5.pm6 multi sub a(@a) { say 1 ~ @a.perl } multi sub a([]) { say 2 ~ [].perl } my @t=(1,2); a([]); a(@t) $ perl6 mmd5.pm6 2[] No applicable candidates found to dispatch to for 'a'. Available candidates are: :(@a) :(Positional ()) in main program body at line 5:mmd5.pm6 $
r31690 -[S04] revise catcher semantics semantics to allow $!.handled = 1 to work as well as case match
Author: lwall Date: 2010-07-15 01:32:07 +0200 (Thu, 15 Jul 2010) New Revision: 31690 Modified: docs/Perl6/Spec/S04-control.pod Log: [S04] revise catcher semantics semantics to allow $!.handled = 1 to work as well as case match Modified: docs/Perl6/Spec/S04-control.pod === --- docs/Perl6/Spec/S04-control.pod 2010-07-14 21:18:42 UTC (rev 31689) +++ docs/Perl6/Spec/S04-control.pod 2010-07-14 23:32:07 UTC (rev 31690) @@ -13,8 +13,8 @@ Created: 19 Aug 2004 -Last Modified: 12 Jul 2010 -Version: 101 +Last Modified: 14 Jul 2010 +Version: 102 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -993,18 +993,46 @@ default {...} } -you're really getting something more like: +you're really calling into a Icatch lambda that looks like: -CATCH { -when Mumble {...} -default {...} +- $! { +my $SUCCEEDED = 1; # assume we will handle it -leave(Failure); +given $! { +when Mumble {...} +default {...} +$SUCCEEDED = 0;# unassume we handled it +} -KEEP (die(Pending exceptions not handled in $!) unless all($!.pending».handled); $!.handled = 1); -UNDO die $!; +# the user may handle exception either by +# 1. pattern matching in the given +# 2. explicitly setting $!.handled = 1 +$!.handled = 1 if $SUCCEEDED; + +# conjecture: this might be enforced by the exception thrower instead +if $!.handled { +$!.wrap-die(Pending exceptions not handled) unless all($!.pending».handled); +} + +$!; } +The exception thrower looks up the call stack for a catch lambda +that returns the exception object as handled, and then it is happy, +and unwinds the stack to that point. If the exception is returned +as not handled. the exception thrower keeps looking for a higher +dynamic scope for a spot to unwind to. Note that any Cdie in the +catch lambda rethrows outside the lambda as a new exception, wrapping +up the old exception in its new pending list. In this case the lambda +never finishes executing. Resumable exceptions may or may not leave +normally depending on the implementation. If continuations are used, +the C$!.resume call will simply goto the continuation in question, +and the lambda's callframe is abandoned. Resumable exceptions may also +be implemented by simply marking the C$! exception as resumed, +in which case the original exception thrower simply returns to +the code that threw the resumable exception, rather than unwinding +before returning. + 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 @@ -1013,7 +1041,7 @@ CCATCH block to catch its own exception recursively forever. However, a CCATCH must not behave that way, so we say that a CCATCH block never attempts to handle any exception thrown within its own dynamic scope. -(Otherwise the Cdie in the previous paragraph would never work.) +(Otherwise any Cdie would cause an infinite loop.) =head1 Control Exceptions @@ -1132,7 +1160,11 @@ that the semantics would be preserved by merely printing out the error and going on. Since all exception handlers run in the dynamic scope of the throw, that reduces to simply returning from the Cwarn -function most of the time. +function most of the time. See previous section for discussion of +ways to return from catch lambdas. The control lambda is logically +separate from the catch lambda, though an implementation is allowed +to combine them if it is careful to retain separate semantics for +catch and control exceptions. =head1 The goto statement Xgoto
[perl #76510] [BUG] =:= doesn't seem to work as spec'd in Rakudo
# New Ticket Created by Carl Mäsak # Please include the string: [perl #76510] # in the subject line of all future correspondence about this issue. # URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76510 lue rakudo: my $a = 3; my $b := $a; my $c = 3; say $a =:= $b; say $a =:= $c p6eval rakudo c8b6cf: OUTPUT«00» lue O.o masak lue: same value, different containers. masak lue: $a and $b should be the same, though lue that's where the O.o comes in. Apparently, =:= is in cheats/ masak lue: you can fix it; I know you can! * masak submits rakudobug S03: 'There is also an identity test, C=:=, which tests whether two names are bound to the same underlying variable. C$x =:= $y would return true in the above example.' And the 'above example' is very similar to the line in the bug report: my $x = 'Just Another'; my $y := $x; $y = 'Perl Hacker';
r31691 -[S04] more bombastic utterances about not dropping pending exceptions
Author: lwall Date: 2010-07-15 01:53:05 +0200 (Thu, 15 Jul 2010) New Revision: 31691 Modified: docs/Perl6/Spec/S04-control.pod Log: [S04] more bombastic utterances about not dropping pending exceptions Modified: docs/Perl6/Spec/S04-control.pod === --- docs/Perl6/Spec/S04-control.pod 2010-07-14 23:32:07 UTC (rev 31690) +++ docs/Perl6/Spec/S04-control.pod 2010-07-14 23:53:05 UTC (rev 31691) @@ -1043,6 +1043,16 @@ never attempts to handle any exception thrown within its own dynamic scope. (Otherwise any Cdie would cause an infinite loop.) +Any attempt to throw a fatal exception past an already active exception +handler must guarantee to steal the existing fatal exception (plus +any pending exceptions it contains) and add all those to the new +exception's pending list. (This does not apply to control exceptions +described in the next section.) When the new exception is handled, +it must also deal with the list of pending exceptions, or the Cwrap-die +mentioned above will throw a Pending exceptions not handled at that point. +Even this does not discard the pending exceptions, so in the final outermost +message, all non-handled exceptions are guaranteed to be listed. + =head1 Control Exceptions All abnormal control flow is, in the general case, handled by the
Re: [perl #76376] [PATCH] Temporal and Date revision
I have rebased the patch to the latest master branch. The latest patch replaces the existing two. On Tue, Jul 13, 2010 at 1:21 PM, Moritz Lenz via RT perl6-bugs-follo...@perl.org wrote: Could you please rebase the patch? It doesn't apply cleanly, and I don't know if I find the motivation to hand-apply it. (Seriously, git could do better, IMHO) 0001-Temporal-Date-modifications-and-refactoring.patch Description: Binary data