perl6 taint & other traits

5 views
Skip to first unread message

BÁRTHÁZI András

unread,
Apr 17, 2005, 3:52:14 PM4/17/05
to perl6-l...@perl.org
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

Luke Palmer

unread,
Apr 17, 2005, 6:32:00 PM4/17/05
to BÁRTHÁZI András, perl6-l...@perl.org
BÁRTHÁZI András 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

Reply all
Reply to author
Forward
0 new messages