Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Fun with Typed Objects 1

by erikharrison (Deacon)
on Apr 03, 2003 at 06:07 UTC ( #247688=note: print w/ replies, xml ) Need Help??


in reply to Fun with Typed Objects 1

Actually, there was some talk of a solution to this. It works in this, somewhat handwavy way.

The declaration my Dog $spot is not enough to instantiate the object itself. After all, you might want my Dog $spot = new Poodle.

But it might be enough typing to allow you to call Dog class methods on it, assuming that it is still undef. Which ties in with a somewhat bizzare use of an augmented assignment operators for the method call operator . resulting in  my Dog $spot .= new (name=>"Fido");

I could live with that . . .

Cheers,
Erik

Light a man a fire, he's warm for a day. Catch a man on fire, and he's warm for the rest of his life. - Terry Pratchet


Comment on Re: Fun with Typed Objects 1
Select or Download Code
Re: Re: Fun with Typed Objects 1
by John M. Dlugosz (Monsignor) on Apr 03, 2003 at 16:08 UTC
    I like the way that is going. I thought about class methods after reading Aristotle's post. I think what you describe is very well defined, too: the .= notation means to use the declared type of a variable and call a class method. To prevent surprises in a more general use, perhaps .= should use the actual object if it exists, but allow undef value to pull the declared type.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2014-09-02 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls