perl6 taint other traits

2005-04-17 Thread BÁRTHÁZI András
Hi,
In Perl5 there can be a flag on a variable, that shows, if it's tainted 
or not. I would like you to ask, if it will be possible the same with 
Perl 6, or - and I'm most interested in this -, if it's possible to 
create something like this by me (defining meta information on 
variables, that not just stored, but has some effect)?

And, maybe it's the same question, is it possible to declare 
traits/properties on a variable, or I just can use the ones that 
declared by the language (and I've misunderstood the conception)?

Bye,
  Andras


Re: perl6 taint other traits

2005-04-17 Thread Luke Palmer
BRTHZI Andrs writes:
 Hi,
 
 In Perl5 there can be a flag on a variable, that shows, if it's tainted 
 or not. I would like you to ask, if it will be possible the same with 
 Perl 6, or - and I'm most interested in this -, if it's possible to 
 create something like this by me (defining meta information on 
 variables, that not just stored, but has some effect)?

Indeed it is possible.  A property is allowed to (re)define methods
of the object that it is being applied to, and you're allowed to
MMD dispatch on objects with a certain property.

enum tainted untainted;

multi sub infix:+(tainted $a, $b) { 
(($a but untainted) + $b) but tainted;
}
# ...

my $x = =$*IN but tainted;
my $y = 10;

my $z = $x + $y;   # z is now tainted

Luke