Eh?

chaoticset on 2003-07-14T15:32:56

I'm doing something that's probably stupid (yes, again).

I was really tired last night and it occurred to me that it could be handy to be able to smush objects together and call one object like it was two different objects.

"Objects? You can play with them however you like," I hear you saying. True. However, if you're going to the trouble of smushing objects together, and usually you're getting your object from a module (a la CGI, HTML::Template, etc.), then wouldn't it just be easier to have some sort of thing that smushes them together for you?

And, following a dastardly and insane sort of reasoning, I've cobbled together the rough notion of the Smush module.

The idea is that, instead of use HTML::Template; and use CGI qw( params ); you would put in use Smush qw( HTML::Template CGI->params ); and it would let you call a Smush object that was an HTML::Template object but also had a params sub that acted exactly like the CGI params sub. The truly bored could have use Smush qw( HTML::Template CGI ); and would get a Smush object that acted like both.

I haven't the faintest clue if this sounds vaguely useful or not (it does to me, but I just learned about closures last week, too). I just want to see if it's possible, and I'm pretty sure it is.


Use Class::Delegation

merlyn on 2003-07-14T16:32:22

Already in the CPAN, from the Mad Scientist from Down Under.

Ruby

djberg96 on 2003-07-14T16:55:14

Dude, you really need to check out Ruby, where forwarding, delegation and mixins are all fairly mundane things.