Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^3: A little overloading conundrum

by ysth (Canon)
on Mar 08, 2026 at 03:22 UTC ( [id://11167419]=note: print w/replies, xml ) Need Help??


in reply to Re^2: A little overloading conundrum
in thread A little overloading conundrum

If you are working around it in the caller, this is clearer, if not as efficient:
my $n2 = -($A_obj - $B_obj);

Replies are listed 'Best First'.
Re^4: A little overloading conundrum
by syphilis (Archbishop) on Mar 08, 2026 at 04:38 UTC
    If you are working around it in the caller...

    Apologies - I should have explicitly stated that "working around it in the caller" is not a solution.
    It's imperative that, wrt the given pseudo-example, my $n2 = $B_obj - $A_obj; return a module A object with a value of -10.
    Hence my agreement with sw1's labelling of both his and my alterations to the caller as being "not practical".

    If module B did not overload the '-' operator then, AIUI, my $n2 = $B_obj - $A_obj; would invoke module A's overloading of that operator - which is exactly what I want.
    I was hoping there might have been some way of triggering that same behaviour when module B does overload that operator .... but it seems that's not the case.

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11167419]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2026-04-21 15:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.