On Sunday 27 June 2004 15:43, Patrick May wrote:
> Sean,
>
> On Sunday, June 27, 2004, at 06:13  PM, Sean O'Dell wrote:
> > The internal Ruby code, in a lot of places, assumes the type of object
> > that
> > self points to.  This kind of assumption is the one that brings out the
> > crashes.  This is the real hurdle.  If every internal checked its own
> > self
> > type before trying to use it, and degraded gracefully when it doesn't
> > have
> > the right internal data, this feature would be perfectly safe.
>
> Requiring a check that self is consistent before an object does
> anything useful doesn't sound like fun.
>
> class SomeClass
>    def a_method
>        raise "I'm not myself" unless (self.class.kind_of? SomeClass)
>         ...
>    end
>
>    def another_method
>        raise "I'm not myself" unless (self.class.kind_of? SomeClass)
>        ...
>    end
>
>     ... ad nauseum...
> end
>
> I think there are other languages that require you to be a strong
> typist, if that is what you are interested in.... :-)

Well, in C extensions you have typing, period; you can't get around that.  In 
C you quite often have no choice but to check your type.  In fact, the vast 
majority of security hacks arise out of C programmers not checking variables 
for type and/or size.  It's results in buffer overflow-style hacks that not 
only result in software de-stabilization, attackers can sometimes gain 
permissions through them.

Besides, the Ruby internals have a set of static Ruby types that, whether you 
like strong typing or not, are very static, very typed and will explode as 
well as anything else if you use them without checking what type you are 
using and whether it's been initialized properly or not.  File, Hash, Array, 
String, FixNum and some others are all static, internal Ruby types that are 
very static and you simply can't treat them in C like you do in Ruby code.

As far as Ruby classes, they have instance @variables, and it's far less of an 
issue.  If you try to use an instance @variable that isn't there, or does 
something you don't expect, that's simply known as "duck typing."  Just use 
the variable and hope for the best.

	Sean O'Dell