Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: On timely destruction?

by Elian (Parson)
on Aug 28, 2002 at 08:33 UTC ( #193392=note: print w/ replies, xml ) Need Help??


in reply to Re: On timely destruction?
in thread On timely destruction?

Well, that's one way to go about it. For something like that, where the data element has some sort of restrictions on it, you're much better off using typed data for the element you need to have escape, and let the class the data is blessed into pitch a fit in the event an assignment to it violates the constraits on that data. Since typed data can overload assignment, it's an easy way to have action-at-a-distance validation of data going into variables.

That eliminates the need for proxy objects and suchlike hackery, and provides a cleaner interface. I expect someone (like, say... you? :) will come up with a constraints module such that you can say:

my $foo has constraint({length $^a < 12});

To allow tagging on contstraint conditions. (Assuming, in this case, that constraint takes a list of closures which all must return true to allow the assignment) Modulo proper perl 6 syntax, of course.


Comment on Re: Re: On timely destruction?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2014-07-28 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (210 votes), past polls