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

Re: questions about bless's second argument

by tybalt89 (Prior)
on Nov 20, 2020 at 00:13 UTC ( #11123865=note: print w/replies, xml ) Need Help??

in reply to questions about bless's second argument

Bless is not just for constructors!

The sample code in this post Re: Use cases for 'sub Pckg::func { }' ? shows a parser for arithmetic expressions that builds a parse tree (AbstractSyntaxTree) consisting of anonymous arrays blessed into a package named for the operation it should perform. I can then get the value of the entire tree just by sending the method ->value to the head of the tree and rely on perl's polymorphism to execute the value sub in the correct package.

The sub "node" does the blessing into any requested package.

  • Comment on Re: questions about bless's second argument

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2021-03-07 11:57 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (120 votes). Check out past polls.