Re: How to implement both object->method and module::function interfa ce?
[email protected] (Hildo Biersma) Wed, 09 Aug 2000 17:13:42 +0100
| Newsgroups | perl.perl6.stdlib |
|---|---|
| Organization | Morgan Stanley Dean Witter & Co. |
| Message-ID | <[email protected]> |
Chaim Frenkel wrote: > > >>>>> "HB" == Hildo Biersma <[email protected]> writes: > > HB> There's a reason people use objects - if only to give the user a handle > HB> to wrap the module's state. Any module that supports both OO and > HB> procedural usage is basically a singleton - only one instance exists at > HB> any one time (at least in procedural mode). For most modules, this > HB> doesn't and shouldn't make sense. > > Sorry, this doesn't make sense. Please explain the difference between > > $foo->twiddle and twiddle $foo > > Or to go to a more specific domain > > $fh = new File::Text "blah" open($fh, "blah") > $txt = $fh->read $txt = <$fh> > > etc. > > There is nothing preventing a procedural interface. One only needs a > handle. The original discussion was in the context of providing the same API for object and method calls. Of course I am aware that subroutines, using handles, can do the same as objects - after all, that's the way objects are implemented. of objects. To get back at my earlier statement: if you want to provide the same API for object calls and procedural calls, in the fashion of CGI, where the procedural interface does not provide a handle, then you're basically tied to a singleton. Hildo