Group: comp.lang.ruby
From: "Rule.rule"
Date: Sunday, February 17, 2008 5:08 PM
Subject: Re: Ruby type-safe? Ruby strongly/weakly typed? Ruby pitfalls?

On Feb 6, 3:20 am, Phlip wrote:
> > Criticism
> > - Lack of variable declarations
>
> This is false to facts. You declare a variable by assigning it for the
> first time. Hence its strongly bonds with its first variable's type.
>
> > - Dynamic typing
> > - Overloaded operators
> > - Reflective and meta-programming features
>
> Just because other languages don't have those things don't blame us for
> our freedom!
>
> Responding to the subject line,Rubyis _strongly_ typed, like Smalltalk.
> There's a difference between OO dynamic typing and strong typesafety.
> They are orthogonal, andRubyhas both.

Well, if you read the actual wiki article I was referring to,
you'd see that "strongly type" and "type-safety" have been defined in
many different ways
by different people, so one would first at least have to agree on what
definition
we are talking about.

> You can pass any object into a
> function, and it will call .methods() on that object, no matter what
> their parent type.
>
> That is so obviously a good thing that many "statically typed" languages
> bend over backwards to find some way to provide it. And inRubyyou
> cannot accidentally coerce one type into another. Compare Perl, where
> variables switch between strings, numbers, and, uh, globs, whenever the
> wind blows!

Well, doesnt that sometimes happen in Ruby, too?
Like the examples I included
in the article: (2+3.5) (implicit conversion Fixnum to Float) and (if
42 then "a" else "b" end) (implicit conversion from Fixnum to
TrueClass))

Or if you by "variables switch" mean this?
x = 2; x = "a"
That can happen in Ruby, too, right?

> Phlip

Safety Articles | Usenet Groups | 20lbs in 30 days