[perl #74104] [bug] overloading an operator hides other candidates

2010-04-08 Thread via RT
# New Ticket Created by  Moritz Lenz 
# Please include the string:  [perl #74104]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=74104 >


10:20 <@moritz_> rakudo: class A { }; multi sub infix:<+>(A $, A $) { }; 
  say 3+3
10:20 <+p6eval> rakudo 8c434e: OUTPUT«No applicable candidates found to 
dispatch to
 for 'infix:<+>'. Available candidates are:␤:(A , A 
)␤␤current instr.:
 '_block14' pc 29 (EVAL_1:0)␤»
10:20 <@moritz_> ouch
10:21 <@moritz_> it hides all the outer multis
10:21 <@moritz_> worth a bug report


[perl #74110] [TODO] Capture needs to do Positional and Associative

2010-04-08 Thread via RT
# New Ticket Created by  Moritz Lenz 
# Please include the string:  [perl #74110]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=74110 >


12:07 <@moritz_> rakudo: say Capture ~~ Positional
12:07 <+p6eval> rakudo 8c434e: OUTPUT«0␤»
12:07 < ruoso> that's a rakudobug
12:08 <@moritz_> rakudo: say Capture ~~ Associative
12:08 <+p6eval> rakudo 8c434e: OUTPUT«0␤»
12:08 < ruoso> that's also a rakudobug
12:08 <@moritz_> let's join that into one :-)
12:08 <@jnthn> Aye, capture needs to be marked as doing those two.


Re: Good error messages: going the extra mile

2010-04-08 Thread Moritz Lenz



Am 07.04.2010 01:16, schrieb Aristotle Pagaltzis:

Hi Larry (mostly) et al,

this sounds like something STD could try to steal:

*

Okay, this may be going a bit far, but how else are you going
to fall completely in love with a compiler?

   $ cat t.c
   void f0() {
   <<<  HEAD
   int x;
   ===
   int y;
   >>>  whatever
   }
   $ clang t.c
   t.c:2:1: error: version control conflict marker in file
   <<<  HEAD
   ^
   $ gcc t.c
   t.c: In function ‘f0’:
   t.c:2: error: expected expression before ‘<<’ token
   t.c:4: error: expected expression before ‘==’ token
   t.c:6: error: expected expression before ‘>>’ token

Yep, clang actually detects the merge conflict and parses one
side of the conflict. You don't want to get tons of nonsense
from your compiler on such a simple error, do you?


As I understood it from a YAPC keynote a year or two ago, STD
already has the speculative parse machinery in place. It seems
like this should be implementable with reasonable effort?


I hope this patch implements this:

http://moritz.faui2k3.org/tmp/version-control-markers.patch

but I can't test it currently (wrong $location).
It looks for version control markers in infix and term position, which 
is most likely to catch such things at line boundaries. It could be 
factored out into a subrule that's called by both term:something and 
infix:something to avoid code duplication.


Cheers,
Moritz


[perl #74112] [BUG] You can hash-index a string in Rakudo

2010-04-08 Thread Carl Mäsak
# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #74112]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=74112 >


 rakudo: say '16'{'%x'}
 rakudo 8c434e: OUTPUT«1␤»
* masak submits rakudobug
 wtf is it parsing that as...
 you tell me.
 std:  say '16'{'%x'}
 std 30331: OUTPUT«ok 00:01 108m␤»
 well, yes, but... :)
 I mean, I guess it's just a hash index into a string, but it
shouldn't work...
 no.
 it shouldn't.


[perl #74130] [PATCH] Allow rakudo to use .pm6 files

2010-04-08 Thread via RT
# New Ticket Created by  Ingy dot Net 
# Please include the string:  [perl #74130]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=74130 >


Hi,

I patched rakudo to look for .pm6 modules in addition to .pm modules and to
use .pm6 over .pm if they are in the same directory. This was agreed upon
between Larry and Jonathan on irc today.

Cheers, Ingy


0001-Patched-rakudo-to-look-for-.pm6-modules.patch
Description: Binary data


Re: [perl #74054] is rw in sub signature does not appear to be working

2010-04-08 Thread Richard Hainsworth

Bruce, FYI

False bug. Moritz has already rejected it and I agreed.

I am chasing an error generated by new Rakudo in code that worked well 
in alpha. I thought this was it, it aint.


Havent time at present to return to the chase.

Sorry.

Richard

Bruce Keeler via RT wrote:

On 4/4/2010 7:13 AM, Richard Hainsworth (via RT) wrote:
  

# New Ticket Created by  Richard Hainsworth
# Please include the string:  [perl #74054]
# in the subject line of all future correspondence about this issue.
#http://rt.perl.org/rt3/Ticket/Display.html?id=74054>


using rakudo updated on 4.4.10

perl6
  >  sub aaa (%h is rw) { %h =  Z 1,2,3 }; my %h =  Z 5,4;
aaa(%h); %h.perl.say
{"c" =>  3, "a" =>  1, "b" =>  2}


It seems to me the output should be
{"x" =>  5, "y" =>  4 }
   


Why?


  


r30346 - docs/Perl6/Spec/S32-setting-library

2010-04-08 Thread pugs-commits
Author: masak
Date: 2010-04-08 23:31:08 +0200 (Thu, 08 Apr 2010)
New Revision: 30346

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32::Temporal] big change, based on much discussion

A number of people spent last Sunday discussing various solutions to
the Temporal module. This is the result; probably a better idea to read
the new file rather than the diff. Briefly, the Temporal you're seeing
here is a stripped-down version of CPAN's DateTime; simple, yet powerful.

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 19:28:35 UTC 
(rev 30345)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 21:31:08 UTC 
(rev 30346)
@@ -7,170 +7,218 @@
 
 =head1 AUTHORS
 
-The authors of the related Perl 5 docs
-Rod Adams 
-Larry Wall 
-Aaron Sherman 
-Mark Stosberg 
 Carl Mäsak 
-Moritz Lenz 
-Tim Nelson 
-Daniel Ruoso 
-Dave Rolsky 
-Matthew (lue) 
+Martin Berends 
+(but see FOOTNOTE at bottom)
 
 =head1 VERSION
 
-Created: 19 Mar 2009 extracted from S29-functions.pod and S16-IO.pod
+Created: 19 Mar 2009
 
-Last Modified: 2 Apr 2010
-Version: 6
+Last Modified: 5 Apr 2010
+Version: 7
 
 The document is a draft.
 
 If you read the HTML version, it is generated from the Pod in the pugs
-repository under /docs/Perl6/Spec/S32-setting-library/Temporal.pod so edit it 
there in
-the SVN repository if you would like to make changes.
+repository under /docs/Perl6/Spec/S32-setting-library/Temporal.pod -- if you
+would like to make changes to the document, that's the place to look.
 
-=head1 Temporal
+=head1 Time and time again
 
-Time is just a jumbled iTem.
+Two chief aspects of a Perl 6 synopsis seem to contribute to it having some
+extra volatility: how far it sits from the rest of the data model of the
+language, and how everyday the topic in question is. C has always been
+volatile for these reasons; C doubly so.
 
-Temporal is divided into two parts: date and time.
+The truth is that while there are many interests to satisfy in the case of a
+C module, and many details to take into account, there's also the
+danger of putting too much in. Therefore, Perl 6's C module takes
+the C module on CPAN as a starting point, adapts it to the Perl 6
+OO system, and boils it down to bare essentials.
 
-=head2 Time
+One of the unfortunate traditions that Perl 6 aims to break is that of having a
+set of "core" modules which could better serve the community on CPAN than in
+the Perl core. For this reason, this module doesn't handle all the world's
+time zones, locales, date formatters or calendars. Instead, it handles a number
+of "natural" operations well enough for most people to be happy, and shows how
+those who want more than that can load a module, or roll their own variants.
+Put differently, the below are the aspects of time that are felt to be stable
+enough to belong in the core.
 
-Time is called upon as such:
+=head1 C
 
-=over
+Returns an C representing the current time as measured in atomic
+second since the epoch, suitable for feeding to some of the C
+constructors.
 
-=item Time.new($timesystem = $*CLOCK, $time = $*NOW)
+=head1 C
 
-Creates a new Time object. $timesystem is what clock you wish to use. If 
unspecified, whatever is in $*CLOCK is used. $time specifies the $time, it 
defaults to what is in $*NOW. What you enter in $time should match the format 
that $timesystem is in. $*NOW and $*CLOCK should be specified in the same 
format (i.e., if $*CLOCK is 'unixepoch', $*NOW should be something like 
127666216.432)
-Possible (string!) values for $timesystem (and therefore $*CLOCK) are:
+A C object describes the time as it would appear on someone's
+calendar and someone's clock. You can create a C object from the
+C returned by the C function:
 
-=over
+my $now = DateTime.from_epoch(time);
 
-=item * 12hour
+This is such a common use case, that there's a C constructor
+that does this for you:
 
-=item * 24hour (this and 12hour are essentialy the same system, but for 
simplicity they are separate)
+my $now = DateTime.now();
 
-=item * hextime
+If you're interested in the current date but not the time, you can use
+the C method instead:
 
-=item * unixepoch
+my $today = DateTime.today();
 
-=item * tai
+This has the same effect as doing C; see
+'"Set" methods' below.
 
-=back
+General dates can be specified through the C constructor:
 
-If the time system you want is not up on the list, you are at the mercy of the 
implementation (which can, of course, add in rarer time systems) and/or 
available libraries and other addons. A shortcut to the time (in the default as 
defined by $*CLOCK) is through the $*TIME variable.
+my $moonlanding = DateTime.new( :year(1969), :month(7), :day(16),
+:hour(20), :minute(17) ); # UTC time

r30347 - docs/Perl6/Spec/S32-setting-library

2010-04-08 Thread pugs-commits
Author: masak
Date: 2010-04-08 23:38:21 +0200 (Thu, 08 Apr 2010)
New Revision: 30347

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32::Temporal] adjusted date :)

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 21:31:08 UTC 
(rev 30346)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 21:38:21 UTC 
(rev 30347)
@@ -15,7 +15,7 @@
 
 Created: 19 Mar 2009
 
-Last Modified: 5 Apr 2010
+Last Modified: 8 Apr 2010
 Version: 7
 
 The document is a draft.



A new era for Temporal

2010-04-08 Thread Carl Mäsak
We (mberends and masak) just pushed a commit to S32::Temporal which
completely replaces what we had before. The changes are rooted in
hours of discussion on #perl6, and we feel rather more confident with
what we have now than with what we had before.

That said, discussion is very welcome.

I do want to explicitly credit Dave Rolsky, whose work on the DateTime
family of modules on CPAN has informed much of the current spec,
sometimes to the point of verbatim copying.

The change that just went in is complete in itself, but we still
expect to add the following details to it:

* DateTime::TimeZone
* The methods strftime and strptime
* DateTime::Duration
* ops: $dt + $dur, $dt - $dur, $dt - $dt

Expect these in the next few days or so.

// Carl


Temporal.pod truncate

2010-04-08 Thread John Williams

Small feature request:

  $dt.truncate( :to );
is somewhat ambiguous, since some people start their week on Sunday, while 
the module truncates to Monday.


Would you consider a less ambiguous week truncation?

  $dt.truncate( :to );
  $dt.truncate( :to );

~ John Williams


r30348 - docs/Perl6/Spec/S32-setting-library

2010-04-08 Thread pugs-commits
Author: Darren_Duncan
Date: 2010-04-09 00:09:48 +0200 (Fri, 09 Apr 2010)
New Revision: 30348

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
S32-Temporal : fold nanosecond into second, fixing regression and inconsistency 
with the rest of the Synopsis

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 21:38:21 UTC 
(rev 30347)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-08 22:09:48 UTC 
(rev 30348)
@@ -85,8 +85,7 @@
 :daydefaults to 1   range 1..31
 :hour   defaults to 0   range 0..23
 :minute defaults to 0   range 0..59
-:second defaults to 0   range 0..61
-:nanosecond defaults to 0
+:second defaults to 0   range 0.0..^62.0
 :timezone   defaults to '+' (UTC)
 :formatter  defaults to an iso8601 formatter, see below
 
@@ -110,14 +109,10 @@
 class also explicitly does not check against ambiguous or invalid local times
 caused by Daylight Saving Time.
 
-If you pass in a C<:nanosecond> value greater or equal to one billion (1e9),
-it will be normalized, and the excess seconds will be transferred to the
-C<:second> value.
-
 =head2 "Get" methods
 
-There are methods C, C, C, C, C, C,
-and C, giving you the corresponding values of the C
+There are methods C, C, C, C, C,
+and C, giving you the corresponding values of the C
 object. The C method also has the synonym C.
 
 The method C returns two values, the I and I.
@@ -141,10 +136,7 @@
 The C method returns the day of the year, a value between 1 and
 366.
 
-The method C returns the second as a real number, with the
-fractional part coming from the C value. The methods
-C, C, and C return the nanosecond part
-in the corresponding unit, rounded to an integer.
+The method C returns the second truncated to an integer.
 
 The following methods work as a sort of formatting methods:
 
@@ -171,7 +163,7 @@
 $dt.day = 15;
 
 The same methods exists for all the values you can set in the constructor:
-C, C, C, C, C, C, C,
+C, C, C, C, C, C,
 C and C. Also, there's a C method, which accepts
 all of these as named arguments, allowing several values to be set at once:
 
@@ -192,7 +184,7 @@
 The C method allows you to "clear" a number of time values below
 a given resolution:
 
-$dt.truncate( :to ); # clears minutes, seconds, and nanoseconds
+$dt.truncate( :to ); # clears minutes and seconds
 
 The time units are "cleared" in the sense that they are set to their inherent
 defaults: 1 for months and days, 0 for the time components.



Re: Temporal.pod truncate

2010-04-08 Thread Carl Mäsak
John (>):
> Small feature request:
>
>  $dt.truncate( :to );
> is somewhat ambiguous, since some people start their week on Sunday, while
> the module truncates to Monday.
>
> Would you consider a less ambiguous week truncation?
>
>  $dt.truncate( :to );
>  $dt.truncate( :to );

I had the same thought, actually. I see both pros and cons.

Among the pros: we'll cater to both the Sunday-starters and
Monday-starters out there, just as you say.

Among the cons: we lose the nice symmetry wherein :to clears all
values smaller than days, :to clears all values smaller than
years, etc. :to is still pretty straightforward, but it's a
subtle category error.

Apart from that, I wouldn't mind making the change. Though maybe we
should take a step backward and just remove :to altogether on
the grounds that it doesn't belong, and is more confusing than useful.
:)

// Carl


Re: r30346 - docs/Perl6/Spec/S32-setting-library

2010-04-08 Thread yary
On Thu, Apr 8, 2010 at 2:31 PM,   wrote:
> +month (for example April 31st) or in that non-leap year (for example February
> +29th 1996).

1996 *was* a leap year! Use 2006 (or 2010, or... etc) if you want a
Feb with 28 days.


Re: Temporal.pod truncate

2010-04-08 Thread Mark J. Reed
I think that :to should stay as-is; it truncates to whatever the .week
method returns, and that's Monday-based. It would be too inconsistent for it
to do anything else.   Asking for the latest prior Sunday or any other
weekday is a useful function, but it doesn't really have anything to do with
'truncation'.

I do think that an "unchecked" version of the setters is called for, one
that silently converts out-of-range values rather than throwing an
exception.  That's not an easy thing to implement outside of the library
without duplicating all the range-checking code.

On Thu, Apr 8, 2010 at 6:09 PM, Carl Mäsak  wrote:

> John (>):
> > Small feature request:
> >
> >  $dt.truncate( :to );
> > is somewhat ambiguous, since some people start their week on Sunday,
> while
> > the module truncates to Monday.
> >
> > Would you consider a less ambiguous week truncation?
> >
> >  $dt.truncate( :to );
> >  $dt.truncate( :to );
> d;
> I had the same thought, actually. I see both pros and cons.
>
> Among the pros: we'll cater to both the Sunday-starters and
> Monday-starters out there, just as you say.
>
> Among the cons: we lose the nice symmetry wherein :to clears all
> values smaller than days, :to clears all values smaller than
> years, etc. :to is still pretty straightforward, but it's a
> subtle category error.
>
> Apart from that, I wouldn't mind making the change. Though maybe we
> should take a step backward and just remove :to altogether on
> the grounds that it doesn't belong, and is more confusing than useful.
> :)
>
> // Carl
>



-- 
Mark J. Reed 


Re: A new era for Temporal

2010-04-08 Thread Mark J. Reed
This looks much better.  Thank you.  When can we expect to see the new
version implemented in Rakudo?  Need any help on that front?

On Thu, Apr 8, 2010 at 5:52 PM, Carl Mäsak  wrote:

> We (mberends and masak) just pushed a commit to S32::Temporal which
> completely replaces what we had before. The changes are rooted in
> hours of discussion on #perl6, and we feel rather more confident with
> what we have now than with what we had before.
>
> That said, discussion is very welcome.
>
> I do want to explicitly credit Dave Rolsky, whose work on the DateTime
> family of modules on CPAN has informed much of the current spec,
> sometimes to the point of verbatim copying.
>
> The change that just went in is complete in itself, but we still
> expect to add the following details to it:
>
> * DateTime::TimeZone
> * The methods strftime and strptime
> * DateTime::Duration
> * ops: $dt + $dur, $dt - $dur, $dt - $dt
>
> Expect these in the next few days or so.
>
> // Carl
>



-- 
Mark J. Reed 


r30351 - docs/Perl6/Spec/S32-setting-library

2010-04-08 Thread pugs-commits
Author: masak
Date: 2010-04-09 08:33:32 +0200 (Fri, 09 Apr 2010)
New Revision: 30351

Modified:
   docs/Perl6/Spec/S32-setting-library/Temporal.pod
Log:
[S32/Temporal] oops, 1996 *was* a leap year

Switching to 2006. Neural glitch pointed out by yary++.

Modified: docs/Perl6/Spec/S32-setting-library/Temporal.pod
===
--- docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-09 00:05:41 UTC 
(rev 30350)
+++ docs/Perl6/Spec/S32-setting-library/Temporal.pod2010-04-09 06:33:32 UTC 
(rev 30351)
@@ -105,7 +105,7 @@
 outside of the ranges specified in the list above, you'll get an exception.
 An exception will also be thrown if the particular day doesn't exist in that
 month (for example April 31st) or in that non-leap year (for example February
-29th 1996). By default, no such checking is done against leap seconds. This
+29th 2006). By default, no such checking is done against leap seconds. This
 class also explicitly does not check against ambiguous or invalid local times
 caused by Daylight Saving Time.
 



Unchecked versions of the setters (Re: Temporal.pod truncate)

2010-04-08 Thread Carl Mäsak
Mark (>):
> I do think that an "unchecked" version of the setters is called for, one
> that silently converts out-of-range values rather than throwing an
> exception.  That's not an easy thing to implement outside of the library
> without duplicating all the range-checking code.

Hm, true (it's not an easy thing to implement setting of out-of-range
values outside of the library). But what would it be used for? What's
the advantage of having a "date" corresponding to no actual day?

What I have been considering is something along the lines of
DateTime.is_valid('2010-02-29'), that returns whether constructing
such a DateTime would be legal (in the sense of 'no exceptions
thrown'). It feels comforting to always leave a way for the API
consumer to find things out without resorting to CATCHing exceptions.

// Carl


Re: A new era for Temporal

2010-04-08 Thread Carl Mäsak
Mark (>):
> This looks much better.  Thank you.  When can we expect to see the new
> version implemented in Rakudo?  Need any help on that front?

A preliminary version is already checked in, and works. It's not
full-featured yet, but work is underway. Commits are appreciated, as
always.

 

// Carl