On Fri, Oct 04, 2002 at 06:21:00AM +0000, David Cumming wrote:
> Is there a standard approach to making a module support both 00 and
> procedural interfaces? Any ideas? I just want to create $self if there isn't
> one. $self should inherit all the default properties made by new.

There are two standard approaches: (1) don't, and (2) give them different
names.  The CGI module is an awkward case because of the long legacy of
backwards-compatibility.

Any attempt at dwimmery in this case will likely cause pain & suffering.
Consider, if you will, any method whose arguments are other instances of the
same class (e.g., copy_from).  Then, auto-detecting OO mode vs. procedural
becomes a lot more involved.  Typically, attempts at this lead to clients
becoming confused by accidentally invoking OO mode when they meant procedural,
or vice-versa.

Consider, perhaps, writing one package, either procedural or OO, and a second
which is a wrapper around the first implementing the other paradigm.

Mx.

Reply via email to