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

Re^2: using an object as a variable type

by Random_Walk (Parson)
on Jan 27, 2006 at 14:25 UTC ( #525979=note: print w/ replies, xml ) Need Help??


in reply to Re: using an object as a variable type
in thread using an object as a variable type

Not sure how the title is nonsense, I wish to constrain the behaviour of the variable to that defined in the 'Me' object so is the package not providing the type of the variable ? I am trying to do this using the syntax of threads::shared which I guess is instantiating a threads::shared object and assigning it to the given variable name. I can live with what I have now my $m = new Me (Random); but out of curiosity and to improve my Perl foo I want to discover and emulate how my $val : shared works.

Not sure how eval can help me here, I don't want to trap the errors, I am intending to enforce limits on the varaiable and croak if an attempt is made to assign an illegal value to it.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!


Comment on Re^2: using an object as a variable type
Select or Download Code
Replies are listed 'Best First'.
Re^3: using an object as a variable type
by chromatic (Archbishop) on Jan 27, 2006 at 20:49 UTC
    I am trying to do this using the syntax of threads::shared which I guess is instantiating a threads::shared object and assigning it to the given variable name.

    That's not what it does. It ties the variable in such a way that multiple threads can access it. That's not what the attribute syntax does though; attributes just run a specific piece of code just after Perl compiles the statement. That code can do anything.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-08-05 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (80 votes), past polls