Domains? [Re: r28597 - docs/Perl6/Spec/S32-setting-library]

2009-10-13 Thread Michael Zedeler

yary wrote:

...
  

Also, the domain should define how to compare objects and could provide
details about whether the set is finite, countable or uncountable.


...

Sounds like a role "Domain" that provides methods (off the top of my head)-

ordering - returns Nil if the domain is unordered, or a method
implementing "cmp" if it is ordered

succ, pred- returns Nil if the domain is uncountable, or method
implementing "next item", "prior item" if countable.
  

Exactly.

count - returns Inf if it's an infinite domain, or count of objects if
finite. What if counting is an expensive operation?
In most cases, the developer will know whether the domain is infinite 
and just hardwire the result to Inf.

Then the .. operator can accept anything that does Domain where
ordering is non-Nil, and the ... operator can add the condition that
succ/pred are non-Nil.
  

Yes.

Moreover, I have realized that Domains can solve a lot of other 
problems, such as collations. In English, it makes sense to write 
something like


'a' .. 'z'

but the Danish and Swedish counterparts are

'a' .. 'z' followed by 'æ', 'ø', 'å' (Danish)

and

'a' .. 'z' followed by 'ä', 'ö', 'å' (Swedish)

since there is only one 'z' in unicode (for obvious reasons), collation 
is something separate from the charset, which can be provided in a 
domain. Also, encoding magical month names becomes easy (the double 
parens here are casting to a domain):


my $month = ((DateDomain['en_US', '%b']))'Jan';
$month++;
say $month; # Feb

...and even...

my $date = ((DateDomain['en_US', '%D']))'01/14/2001';
$date++;
say $date; # 01/15/2001

Also, this is an extension of the notion of subtypes, augmenting it with 
ordering and some other relations. Next question is whether the domain 
shouldn't also provide arithmetic.


There is a lot of plumbing to do to fully use this concept, but I 
believe it could be really useful.


Regards,

Michael.

where



[perl #69738] [BUG] Can't use a Rat to index an array in Rakudo

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


 rakudo: my @a = ; say @a[4/3]
 rakudo d749d9: OUTPUT«get_integer() not implemented in class
'Rat' [...]
* masak submits rakudobug


Re: Domains? [Re: r28597 - docs/Perl6/Spec/S32-setting-library]

2009-10-13 Thread Ville Koskinen
On Tue, 13 Oct 2009 09:21 +0200, "Michael Zedeler" 
wrote:
> 'a' .. 'z' followed by 'ä', 'ö', 'å' (Swedish)

'a' .. 'z', 'å', 'ä', 'ö' (Finnish)
'a' .. 's', 'š', 'z', 'ž', 't' .. 'w', 'õ', 'ä', 'ö', 'ü', 'x', 'y'
(Estonian)

So yes, you are definitely on the right track with Domains.

Regards,
Ville Koskinen




[perl #69752] [BUG] 'Module.new' causes 'maximum recursion depth exceeded'

2009-10-13 Thread via RT
# New Ticket Created by  Carlin Bingham 
# Please include the string:  [perl #69752]
# in the subject line of all future correspondence about this issue. 
# http://rt.perl.org/rt3/Ticket/Display.html?id=69752 >


 rakudo: say Module.new
 rakudo d749d9: OUTPUT«maximum recursion depth exceeded␤in Main
(file src/gen_setting.pm, line 206)␤»

--
Carlin



[perl #69740] [BUG] Defining several constants with parentheses doesn't work in Rakudo

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


 perl6: constant ($a, $b) = 1, 2; say "$a $b"
 rakudo d749d9: OUTPUT«No applicable methods. [...]
[...]
 ouch, that looks like a rakudobug
 rakudo: constant $a = 3; say $a
 rakudo d749d9: OUTPUT«3␤»
 i was trying to define many constants in a compact way
 masak: care to submit? :-)
* masak cares to submit
 std: constant ($a, $b) = 1, 2; say "$a $b"
 std 28773: OUTPUT«ok 00:02 115m␤»


[perl #69738] tests available

2009-10-13 Thread kyleha
This is an automatically generated mail to inform you that tests are now 
available in t/spec/S32-num/rat.t

commit 44b611429edf1c19d0bcdafa4abe28ffc16a9afc
Author: moritz 
Date:   Tue Oct 13 12:08:26 2009 +

[t/spec] test for RT #69738: array indexing with Rats

git-svn-id: http://svn.pugscode.org/p...@28778 
c213334d-75ef-0310-aa23-eaa082d1ae64

diff --git a/t/spec/S32-num/rat.t b/t/spec/S32-num/rat.t
index b67ac25..e92d95f 100644
--- a/t/spec/S32-num/rat.t
+++ b/t/spec/S32-num/rat.t
@@ -156,6 +156,9 @@ is( exp(1).Rat(1e-4), Rat.new(193, 71), "Num to Rat with 
epsilon 1e-4");
 is( exp(1).Rat(Rat.new(1,1e4.Int)), Rat.new(193, 71),
 "Num to Rat with epsilon of Rat");
 
+is (5/4).Int,   1, 'Rat.Int';
+is .[4/3],  'b', 'Indexing an array with a Rat (RT #69738)';
+
 done_testing;
 
 # vim: ft=perl6


[perl #69740] tests available

2009-10-13 Thread kyleha
This is an automatically generated mail to inform you that tests are now 
available in t/spec/S04-declarations/constant.t

commit bb301917e805250f795bccf238ad292f33376700
Author: moritz 
Date:   Tue Oct 13 12:20:46 2009 +

[t/spec] Test for RT #69740

git-svn-id: http://svn.pugscode.org/p...@28779 
c213334d-75ef-0310-aa23-eaa082d1ae64

diff --git a/t/spec/S04-declarations/constant.t 
b/t/spec/S04-declarations/constant.t
index fade05c..b207465 100644
--- a/t/spec/S04-declarations/constant.t
+++ b/t/spec/S04-declarations/constant.t
@@ -2,30 +2,37 @@ use v6;
 
 use Test;
 
-plan 33;
+plan *;
 
 # L
 
 # Following tests test whether the declaration succeeded.
 #?pugs todo 'feature'
 {
-my $ok;
-
 constant foo = 42;
-$ok = foo == 42;
 
-ok $ok, "declaring a sigilless constant using 'constant' works";
+ok foo == 42, "declaring a sigilless constant using 'constant' works";
+dies_ok { foo = 3 }, "can't reasign to a sigil-less constant";
 }
 
 {
 my $ok;
 
 constant $bar = 42;
-$ok = $bar == 42;
+ok $bar == 42, "declaring a constant with a sigil using 'constant' works";
+dies_ok { $bar = 2 }, "Can't reasign to a sigiled constant";
+}
 
-ok $ok, "declaring a constant with a sigil using 'constant' works";
+#?rakudo skip 'RT 69740'
+{
+constant ($a, $b) = (3, 4);
+is $a, 3, 'multiple constant in one declaration(1)';
+is $b, 4, 'multiple constant in one declaration(2)';
+dies_ok { $a = 4 }, 'and they are really constant (1)';
+dies_ok { $b = 4 }, 'and they are really constant (2)';
 }
 
+
 {
 {
 constant foo2 = 42;
@@ -239,4 +246,6 @@ plan 33;
  'assign constant its own value from expression';
 }
 
+done_testing;
+
 # vim: ft=perl6


r28780 - docs/Perl6/Spec

2009-10-13 Thread pugs-commits
Author: masak
Date: 2009-10-13 16:51:50 +0200 (Tue, 13 Oct 2009)
New Revision: 28780

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] fixed typo

Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2009-10-13 12:20:46 UTC (rev 28779)
+++ docs/Perl6/Spec/S06-routines.pod2009-10-13 14:51:50 UTC (rev 28780)
@@ -2752,7 +2752,7 @@
 Bare AST variables (such as the arguments to the macro) may not be
 spliced directly into a quasiquote because they would be taken as
 normal bindings.  Likewise, program text strings to be inserted need
-to be specially marked or they will be bound normally.  To insert a
+to be specially marked or they will be bound normally.  To insert an
 "unquoted" expression of either type within a quasiquote, use the
 quasiquote delimiter tripled, typically a bracketing quote of some sort:
 



[perl #65658] tests available

2009-10-13 Thread kyleha
This is an automatically generated mail to inform you that tests are now 
available in t/spec/S12-enums/thorough.t

commit 8785f522e418108dbccd2e289ed6829b6f1ecf83
Author: kyle 
Date:   Wed Oct 14 03:32:23 2009 +

[t/spec] Test for RT 65658

git-svn-id: http://svn.pugscode.org/p...@28783 
c213334d-75ef-0310-aa23-eaa082d1ae64

diff --git a/t/spec/S12-enums/thorough.t b/t/spec/S12-enums/thorough.t
index 66598c6..d6fad0c 100644
--- a/t/spec/S12-enums/thorough.t
+++ b/t/spec/S12-enums/thorough.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 71;
+plan *;
 
 =begin description
 
@@ -110,4 +110,14 @@ ok Bool::True.perl ~~/^ 'Bool::True'/, 'Bool::True.perl';
 eval_dies_ok 'RT66886::c', 'accessing non-value of enum dies proper-like';
 }
 
+# RT #65658
+{
+enum RT65658 ;
+#?rakudo 2 skip 'RT 65658'
+is RT65658(2), RT65658::Feature, 'can index enum by number';
+is RT65658((Todo + 3.2).Int), RT65658::Ticket, 'enum and math and index';
+}
+
+done_testing;
+
 # vim: ft=perl6