Re: lazy-loading objects in perl6 - how will they look?
On Sat, Mar 12, 2005 at 09:21:23PM +0200, Yuval Kogman wrote: : Hola, : : Object::Realize::Later and friends in perl5 get the job done, but : have many caveats. : : Will there be a mechanism to provide a way to do inplace replacement : of an object's, err, thingyness (class, data), without losing it's : identity? : : : I would like a way to transpose objects between classes in the same : instance for several reasons beside lazy loading, btw. : : I think one of the most beautiful uses is to provide protocol : handlers in a state machine style implementation, mainly for : security by simplicity. Sounds like simple delegation to me. The delegation model in Perl 6 lets you specify which methods the delegate handles without committing to the identity or existence of the delegated object. You can probably even get an extra degree of type safety between the delegatee and delegator by using roles to pull in your interfaces. The default implementation for your role's methods could delegate, while the delegated implementation object defines them to do something real. Larry
Re: lazy-loading objects in perl6 - how will they look?
On Sat, Mar 12, 2005 at 21:21:23 +0200, Yuval Kogman wrote: > Hola, > > Object::Realize::Later and friends in perl5 get the job done, but > have many caveats. FYI, Juerd told me how to clean this up with Data::Swap (err, Data::Alias) more cleanly in perl 5. Thanks! -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: *shu*rik*en*sh*u*rik*en*s*hur*i*ke*n*: neeyah pgpuMxB5hftsY.pgp Description: PGP signature
lazy-loading objects in perl6 - how will they look?
Hola, Object::Realize::Later and friends in perl5 get the job done, but have many caveats. Will there be a mechanism to provide a way to do inplace replacement of an object's, err, thingyness (class, data), without losing it's identity? I would like a way to transpose objects between classes in the same instance for several reasons beside lazy loading, btw. I think one of the most beautiful uses is to provide protocol handlers in a state machine style implementation, mainly for security by simplicity. For example, here is the design of a pop3 server (i actually implemented it in perl5 and it wasn't too bad): parse input, regexy, into cmd args format call $backend_obj->cmd(@args); Each command is a method call, and to switch the modes of the statemachine, $backend_obj would rebless itself into different classes, with different commands. The pass command, for example, will transpose the object to the authenticated state, if the user/password pair matches. If it fails it returns to the connected state. The user command is a part of the connected state, and transposes to the accepting password state, a subclass of the connected state. Since method dispatch is quite rigorously tested edge cases are pretty much tested for, and the implementation is very robust, and has very explicit logic, provided you're willing to eat it. I'd like to be able to exploit this more cleanly in Perl 6, and also get easier and safer lazy loading of objects. -- () Yuval Kogman <[EMAIL PROTECTED]> 0xEBD27418 perl hacker & /\ kung foo master: /me whallops greyface with a fnord: neeyah!!! pgpfMiub6SlqJ.pgp Description: PGP signature