Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2021-01-20 23:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?