* Eric Wilhelm <ewilhelm at sbcglobal.net> [2004/01/21 13:58]: > > The following was supposedly scribed by > > darren chamberlain > > on Wednesday 21 January 2004 11:10 am:
"Supposedly"? Aren't you verifying signatures? ;)
> Not exactly. The IO::* modules do not have constructors, and neither
> does IO.pm. Maybe "mix-in" is the wrong term. Essentially, every
> function is inherited *by* CAD::Drawing, so basically, the entire set
> could simply be in the one package and file, but that's a lot of code.
> Maybe they are more like "add-on" packages? Functions from IO::*
> modules are inherited by IO.pm, which is inherited by Drawing.pm, so
> with $d = CAD::Drawing->new(), you could call $d->loaddwg("file.dwg",
> {}), but you are better served by $d->load("file.dwg") where load() is
> actually CAD::Drawing::IO::load() and loaddwg() is
> CAD::Drawing::IO::OpenDWG::loaddwg().
Well, if polymorphism isn't what you're after, couldn't you have
CAD::Drawing::IO not define a load function, and have
CAD::Drawing::IO::Foo declare package CAD::Drawing::IO and define a
load? Then, the user need simply do:
use CAD::Drawing::IO;
use CAD::Drawing::IO::OpenDWG;
And calling load("file.dwg") uses the load defined in ::IO::OpenDWG?
Without any knowledge of the implementation, however, it sounds like
what you want is polymorphism, and you're jumping through hoops to avoid
using it.
> The primary goal is to make the module more easily installable (and
> possibly to eventually pass the CPAN autotesting), but I'd also like
> other authors to be able to write IO::* modules (for other geometric
> formats) without having to add code to IO.pm or make changes to your
> main program (e.g. if you give the program an argument of "output.igs"
> and an iges format save function is available, it just "does the right
> thing".) With this model, your main program would not have "use
> CAD::Drawing::IO::IGES;", but simply "use CAD::Drawing;".
This sounds exactly like DBI, which relies on DBDs being polymorphic.
*shrug*
(darren)
--
If you wish to drown, do not torture yourself with shallow water.
pgp00000.pgp
Description: PGP signature
