Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^6: Making it clearer to say that a sub is defined within current package

by LanX (Saint)
on Apr 11, 2019 at 16:02 UTC ( [id://1232454]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Making it clearer to say that a sub is defined within current package
in thread Making it clearer to say that a sub is defined within current package

I was talking about the need to have a hinthash to restrict the effects of "use My" to the scope.

What are you talking about?

I don't want to collide with any other product which is using My:: for its own purpose. Of course does the caller change.

But any magic should be restricted to the local scope!

Anyway reserving the Namespace on CPAN would be needed.

update

another idea would be using a lexical object, and the method call would be channeled through AUTOLOAD.

my $mysubs = new Mysubs; $mysubs->xyz();

this could indeed work without polluting other packages and the runtime effects would become obvious by the ->arrow .

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^6: Making it clearer to say that a sub is defined within current package
  • Download Code

Replies are listed 'Best First'.
Re^7: Making it clearer to say that a sub is defined within current package
by Eily (Monsignor) on Apr 11, 2019 at 16:08 UTC

    Ah, right. I understood that you were saying that calling My::function from a module that does not define function would yield unexpected results. The actual message makes more sense :D.

    If there are already package that use My:: without having reserved the keyword, they already are risky on their own anyway, if you ever end up including more than one of those in one program.

      my philosophy is that nobody else should try to use my personal footgun for his own limbs. ;-)

      BTW: the object thing could work, but I won't implement it, cause this reeks strongly like an XY problem.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1232454]
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: (4)
As of 2024-04-25 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found