On Fri, Dec 12, 2003 at 04:27:59PM -0500, Austin Hastings wrote: : > -----Original Message----- : > From: Jonathan Scott Duff [mailto:[EMAIL PROTECTED] : > I think I'm getting it but I'm not sure. Does something like this : > work? : > : > my role Teach { ... } : > my role Operate { ... } : > my role Learn { ... } : > : > my Person $frank; : > { temp $frank_the_teacher = $frank does Teach; ... } : > { temp $frank_the_doctor = $frank does Operate; ... } : > { temp $frank_the_student = $frank does Learn; ... } : > : > I.e., we can use dynamic scoping to control how long an object : > fulfills a particular role? Maybe it could also be written like so: : > : > my Person $frank; : > { my role Teach { ... }; $frank does Teach; ... } : > { my role Operate { ... }; $frank does Operate; ... } : > { my role Learn { ... } $frank does Learn; ... } : > : > so that when the role goes out of scope, the object no longer : > possesses the abilities of that role. : > : > I confuse myself everytime I think about this stuff. : : That's brilliant, if twisted. The object persists, but the behaviors expire. : There's a paradigm there, man. Write a book.
The behavior probably doesn't expire unless you've cloned the object and the clone expires. However, if a role goes out of its lexical scope, it can't be named, so it's effectively not usable unless you dig out a name for it via reflection. But the information is still cached there, so the object could be smarter the next time it takes on the same role. That being said, a role applied with C<temp> probably *should* be stripped out when it goes out of scope. Could get messy though... Larry