HaloO,
another self-reply :)
I've added a little hack that classifies strings
into these areas 0 to 3 to illustrate my idea of
a type lattice on which composes the background
of the Perl 6 Type System. Pattern matching and
type systems are related but the question for
Perl 6 is: how exactly?
The topmost type Any has a very nice mnemonic: it's
the any-junction of all types that have no direct
supertype---their lub. Likewise there could be a None
that is the none-junction of all types that have no
subtype---their glb.
This means the Any actually depends on the loaded
program. If it only uses e.g. the unrelated types
A, B and C then Any is A|B|C. Likewise for programs
that implicitly handle strings and do numerics one
gets Any = Str|Num.
BTW, are Num and Int distinct or is there a
relation: Int is/does Num?
Regards,
--
TSa (Thomas Sandla�)
#! /usr/bin/perl
$s = @ARGV[0];
if ($s =~ /(^aa.*$)|(^.*bb$)/) # perl6: $s ~~ m:overlap/(^aa.*$)|(^.*bb$)/
{
print "success: <$1> <$2>\n";
}
else
{
print "match: <$1> <$2>\n";
}
if ($s =~ /^aa.*$/ || $s =~ /^.*bb$/ || $s =~ /^.*aa.*bb.*$/) { print "<: A|B\n"; }
if ($s !~ /^aa.*$/ && $s !~ /^.*bb$/ && $s !~ /^.*aa.*bb.*$/) { print "<: none(A,B)\n"; }
if (($s =~ /^aa.*$/ && $s !~ /^.*bb$/) ||
($s !~ /^aa.*$/ && $s =~ /^.*bb$/) ) { print "<: A^B\n"; }
if ($s =~ /^aa.*$/) { print "<: A\n"; }
if ( $s =~ /^.*bb$/) { print "<: B\n"; }
if ($s =~ /^aa.*$/ && $s =~ /^.*bb$/) { print "<: A&B\n"; }
print "===================================\n";
if ($s =~ /(aa.*)/) { print "aa = $1\n"; }
if ($s =~ /(.*bb)/) { print "bb = $1\n"; }
if ($s =~ /aa.*/ || $s =~ /.*bb/) { print "<: A|B\n"; }
if ($s !~ /aa.*/ && $s !~ /.*bb/) { print "<: none(A,B)\n"; }
if (($s =~ /aa.*/ && $s !~ /.*bb/) ||
($s !~ /aa.*/ && $s =~ /.*bb/) ) { print "<: A^B\n"; }
if ($s =~ /aa.*/) { print "<: A\n"; }
if ( $s =~ /.*bb/) { print "<: B\n"; }
if ($s =~ /aa.*/ && $s =~ /.*bb/) { print "<: A&B\n"; }