in reply to Pretending to be lisp: macros
You could do something like this with Class::MakeMethods easily enough:
package MyObject; use Class::MakeMethods::Autoload { 'new' => 'Template::Hash::new', '.*' => 'Template::Hash::scalar -self_closure', }; package main; my $object = MyObject->new(); my $new_func = $object->attrib(); $new_func->('value');
The Class::MakeMethods::Autoload statement says that we want to generate a constructor for "new", and for any other method name we want to construct a "scalar -self_closure" method.
The "-self_closure" flag informs Class::MakeMethods that you don't want a simple accessor -- you want to return a closure bound the the target object that will act as an accessor.
|
|---|