From: Eero Saynatkari Date: 2006-08-18T06:32:16+09:00 Subject: Re: Perl Junkie: Bad form? /usr/ceo wrote: > Ok where do I start? :-) A little background... > > I've been declaring up and down for 6 years now I'm going to stop using > Perl and start using Ruby. One thing that has always held me back is > not having libraries I've put together in Perl available to me in Ruby. > Instead, I've ported little Ruby tricks over into Perl to the extent > possible. Now I've decided the only way I'm going to use Ruby is start > porting some of the stuff I use in Perl to Ruby. > > Here's a little bit of a delimma I have going that I hope to illustrate > using something simple. > > I wrote this routine in Perl called "puts" that mostly simulates Ruby's > "puts" statement. (I intend to illustrate something bigger than "puts" > emulation here, so don't let that drag you in. I'm more interested in > the module interaction and EXPORTS [in Perl] and include [in Ruby] > interaction...). Here's the puts() routine in Perl: > > > > This is what I would rather be doing, generally, for imported utility > type routines -- making them look "native." I understand (pretty much) > about the separate namespace issue, and namespaces are certainly nice > (both in Perl and in Ruby). But sometimes I want to pretend I have > something "natively" available to me, and this seemed to work. > > Ugly? Right? Hackish? A better way? Looking for the Ruby > perspective here because this is probably one of my more unsolved > delimmas -- how to view, approach and implement cases like this. The problem is you might be tromping all over the library user's namespace, possibly overriding methods etc. It is better to give the 'namespace' and then allow the client programmer #include the module if they desire shorter access. Those who remember, I actually advocate allowing the client programmer create a namespace for libraries instead of the library writer, too, but that is another discussion. > Thanks! > /usr/ceo -- Posted via http://www.ruby-forum.com/.