Re: How to implement both object->method and module::function interfa ce?
[email protected] (Michael Fowler) Tue, 8 Aug 2000 13:47:48 -0800
| Newsgroups | perl.perl6.stdlib |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 08, 2000 at 02:22:20PM -0500, Garrett Goebel wrote: > What's the conventional wisdom on creating a module that supports both an OO > and non-OO interface? Are there any CORE or CPAN modules to serve as a > textbook, or is the anwser "Don't do that"? > > I've got some code that checks the first parameter passed to see if it is a > reference, assumes any reference is an object reference... and then proceeds > accordingly. -It feels pretty sloppy, but it works. I don't think there's conventionial wisdom to doing this, it depends entirely on your application. The problem is that if you're using OO you have a nice little reference implicitly passed around that you can store state information and such in. It's difficult to move this over to a purely procedural design, unless your application allows for it in some way. If you can manage it intelligently, the answer is most definitely "do that!". Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --