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:

*http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html

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


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 r...@rodadams.net
-Larry Wall la...@wall.org
-Aaron Sherman a...@ajs.com
-Mark Stosberg m...@summersault.com
 Carl Mäsak cma...@gmail.com
-Moritz Lenz mor...@faui2k3.org
-Tim Nelson wayl...@wayland.id.au
-Daniel Ruoso dan...@ruoso.com
-Dave Rolsky auta...@urth.org
-Matthew (lue) rnd...@gmail.com
+Martin Berends mbere...@autoexec.demon.nl
+(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. CS32 has always been
+volatile for these reasons; CS32::Temporal 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
+CTemporal module, and many details to take into account, there's also the
+danger of putting too much in. Therefore, Perl 6's CTemporal module takes
+the CDateTime 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 Ctime
 
-=over
+Returns an CInstant representing the current time as measured in atomic
+second since the epoch, suitable for feeding to some of the CDateTime
+constructors.
 
-=item Time.new($timesystem = $*CLOCK, $time = $*NOW)
+=head1 CDateTime
 
-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 CDateTime object describes the time as it would appear on someone's
+calendar and someone's clock. You can create a CDateTime object from the
+CInstant returned by the Ctime function:
 
-=over
+my $now = DateTime.from_epoch(time);
 
-=item * 12hour
+This is such a common use case, that there's a CDateTime.now 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 Ctoday method instead:
 
-=item * unixepoch
+my $today = DateTime.today();
 
-=item * tai
+This has the same effect as doing CDateTime.now().truncate('day'); see
+'Set methods' below.
 
-=back
+General dates can be specified through the Cnew constructor:
 
-If the time system you want is not up on the list, you are at the mercy of the 
implementation 

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( :toweek );
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( :tosunday );
  $dt.truncate( :tomonday );

~ John Williams


Re: Temporal.pod truncate

2010-04-08 Thread Carl Mäsak
John ():
 Small feature request:

  $dt.truncate( :toweek );
 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( :tosunday );
  $dt.truncate( :tomonday );

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 :today clears all
values smaller than days, :toyear clears all values smaller than
years, etc. :tomonday 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 :toweek 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,  pugs-comm...@feather.perl6.nl 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 :toweek 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 cma...@gmail.com wrote:

 John ():
  Small feature request:
 
   $dt.truncate( :toweek );
  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( :tosunday );
   $dt.truncate( :tomonday );
 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 :today clears all
 values smaller than days, :toyear clears all values smaller than
 years, etc. :tomonday 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 :toweek altogether on
 the grounds that it doesn't belong, and is more confusing than useful.
 :)

 // Carl




-- 
Mark J. Reed markjr...@gmail.com


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 cma...@gmail.com 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 markjr...@gmail.com