[EMAIL PROTECTED] kirjoitti:
Please,
I have a question if exists in Perl somethink like keyword
'operator' in C++ ?
That will exist in perl6.
for example we can write in C++ :
class A {
A() { printf("Constructor of object class A\n"); }
~A() { printf("Destructor of object class A\n"); }
};
A &operator + (A &a1, A &a2) { printf("Addition\n"); }
A &operator * (A &a1, A &a2) { printf("Multiplication\n"); }
>
> int main() {
> A a,b,c;
> c = (a+b*a);
> }
Using these as reference:
http://dev.perl.org/perl6/synopsis/S06.html
http://dev.perl.org/perl6/synopsis/S12.html
(I don't understand how to create constructor & destructor)
I think equivalent perl6-code would be:
class A {
# place constructor here
# place destructor here
}
sub infix:<+> (A $a1, A $a2) { print("Addition\n"); }
sub infix:<*> (A $a1, A $a2) { print("Multiplication\n"); }
my A $a; # note, I'm not sure how to write this on one line
my A $b;
my A $c;
$c = ($a + $b * $a);
--
Markus Laire
<Jam. 1:5-6>