Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: questions about bless's second argument

by tybalt89 (Monsignor)
on Nov 20, 2020 at 00:13 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123865]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 03:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found