[Chicago-talk] import as initialize?

Steven Lembark lembark at wrkhors.com
Tue Mar 14 09:24:07 PST 2006

Jim Thomason wrote:
 > Is there a community consensus on how import should be used?


 > Personally, I really like the concept of using the thing as a class
 > initialize method as such things exist in other languages. I've even
 > been known to do it a few times. It's just so convenient to use it as
 > a class initialization method.
 > But, alas, I also know that it doesn't work very well to do that due
 > to the simple fact that you can use a module with empty parens or
 > require it and completely skip over that step of calling ->import
 > automagically. Voila, your class is unitialized and things break
 > spectacularly.

You are overloading the import method if you use it
for package init. The thing is intended for exporting
symbols, etc. If the module is used in multiple places
you may end up re-init'ing it several times, which is
usually not a good thing.

 > So is there some other handy dandy way to do class initialization
 > other than using this more-fragile-than-I'd like approach of import?

Q: What is wrong with BEGIN (compile time) or INIT (runtime) blocks?

Steven Lembark                                         85-09 90th Street
Workhorse Computing                                  Woodhaven, NY 11421
lembark at wrkhors.com                                      +1 888 359 3508

More information about the Chicago-talk mailing list