On Tue, Aug 17, 2010 at 6:49 PM, Aaron Sherman <a...@ajs.com> wrote: > On Tue, Aug 17, 2010 at 6:48 PM, Aaron Sherman <a...@ajs.com> wrote: >> On Tue, Aug 17, 2010 at 11:51 AM, Moritz Lenz <mor...@faui2k3.org> wrote: >> >>> Aaron Sherman wrote: >>> > I did eventually discover that I needed to do this. The problem then >>> > became that I can't reliably get exporting an infix:<+> operator from a >>> > module to work. >>> >>> When you try, make sure to declare it as 'our', since Rakudo doesn't >>> fully handle lexical exports yet. >>> >>> # probably also needs type constraints >>> our multi sub infix:<+>($a, $b) is export { >>> # your code here >>> } >>> >> >> This is what my signature looks like right now (I've re-named my module >> BigTest just to avoid confusion while I develop): >> >> our multi sub infix:<+>(BigTest $lhs, BigTest $rhs) is export { >> return BigTest.new(:value(Q:PIR { >> ... >> }; >> } >> >> When I "use" that file, and try to add: >> >> ./perl6 -e 'use BigTest; my BigTest $i .= >> new(:value("1000000000000000000000000")); $i = $i + $i; say $i' >> >> I get: >> >> Type check failed for assignment >> in '&infix:<=>' at line 1 >> in main program body at line 1 >> >> If I comment out the Numeric method in my class, then that error changes >> to: >> >> Can't take numeric value for object of type BigTest >> in 'Any::Numeric' at line 1339:CORE.setting >> in 'infix:<+>' at line 6752:CORE.setting >> in main program body at line 1 >> >> So it looks like it's just totally unwilling to try to use that inline:<+> >> that I've defined, and instead is dead-set on trying to convert my BigTest >> to a Numeric in order to match an alternate signature.
I believe this is probably something funky about using -e. At least, from the REPL: > use Math::Vector _block98 > my $a = Math::Vector.new(0.0, 1.0, 2.0); (0, 1, 2) > say $a + $a Can't take numeric value for object of type Math::Vector but the following script: use Math::Vector; my $a = Math::Vector.new(0.0, 1.0, 2.0); say $a + $a; works fine, generating (0, 2, 4) as its output. -- Solomon Foster: colo...@gmail.com HarmonyWare, Inc: http://www.harmonyware.com