>> my $plain = $c - $d : Math::Complex # 3.0 + 0i >> sqrt(2 : Math::Integers) # -> exception or not-a-number
>Not a bad idea,. I beleive that the perl6 adjective operator >(for functions) will be a semicolon, not a colon. I'm not >sure how it is planned to apply it to operators. > >Its also plausable to use properties: > >my $plain2 is Math::Complex = $c - $d. > >That would require overloading the '-' operator based on >return type; and could get a bit nasty. > The nice thing about being per-operation (or per-function) is that in some cases, the place where you want to define the operation is not alone defined by the operands. Is more like a kind of enviroment where things happen. While most cases can be handled with a rich type system, others do need explicit information about the structure where the operation is defined (although, to be honest, they are probably the lesser). [The example I've got in mind is factoring a polynomal, where the type of the object (Polynomal of real parameters) doesn't determine the place where you factor it (over Q, R, a finite extension, ...? ) ] A second one (probably more important) is that with adverbs you can use both classes (Math::Complex) and instance objects ( Math::FiniteFields::F(8) ) as long as they have the right set of methods. I don't know if you can say : my $plain2 is $structureObject = $c - $d; do you? This allows structures to be user-constructed objects if needed (and only if needed), and thus in theory (probably only in theory) you could even define an algebra of structures. And finally, I find some syntatic pleasure in: print [0,2,3] * [1,3,4] : $myEuclidianSpace; -angel who must have taken the rant pill today...