From: Bill Kelly Date: 2004-06-26T06:30:09+09:00 Subject: Re: Is it considered Harmful? From: "Sean O'Dell" > On Friday 25 June 2004 09:16, Bill Kelly wrote: > > Supposed an object's class were changed to a different class > > which was itself (or whose ancestor(s) were) implemented in 'C' > > code. Something that expects that once it's initialized it > > can go ahead and rely on its class invariants pointing to real > > operating system file handles, window handles, etc. > > No code should "expect" data to be there that isn't. :) No ambulator should "expect" the rug to remain steady under their feet when it might be pulled out from under them. And yet - we live by many such expectations just to make it through every day life. One such expectation, for me, is that when my constructor or initializer (whether it be C or C++ or Ruby or Java or Perl or Python or.....) sets up some private member variables in my object - it is reasonable for me to expect that they won't be tampered with by unexpected external tomfoolery. > If a C extension wraps a > native C struct as a Ruby object with Make_Struct, then when it unwraps it, > and gets nothing or a NULL pointer, it shouldn't continue to try and use it. > That's sloppy coding. I'm just getting started writing ruby extensions, so I have a lot to learn. Regards, Bill