[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Non-declared variables

Avatar

10/16/2006 11:38:00 AM

I would like to hear people's opinions on the ability to use variables
without declaring them in dynamic languages like Ruby.

It would seem to me that an argument for non-declared local variables
that typically occupy a small scope could be made. But, class
variables? What is the benefit in allowing for runtime definition of
class variables?

Are there real tangible benefits that non-declared, dynamically typed
(at binding time) variables provide? Or do dynamic variables simply
create less compile time errors and more (harder to catch) runtime
errors?

Thoughts?

5 Answers

Ken Bloom

10/16/2006 1:26:00 PM

0

On Mon, 16 Oct 2006 04:38:09 -0700, Avatar wrote:

> I would like to hear people's opinions on the ability to use variables
> without declaring them in dynamic languages like Ruby.
>
> It would seem to me that an argument for non-declared local variables
> that typically occupy a small scope could be made. But, class
> variables? What is the benefit in allowing for runtime definition of
> class variables?
>
> Are there real tangible benefits that non-declared, dynamically typed
> (at binding time) variables provide? Or do dynamic variables simply
> create less compile time errors and more (harder to catch) runtime
> errors?
>
> Thoughts?

I was programming in Java last week, and writing typed code. I found that
after about an hour of coding, my code would have worked correctly (it
would have been less time if Java supported operator overloading the way
ruby does), but I still had to spend another hour getting the types
appropriately declared, and typecasting things correctly as I pulled
objects out of their various collections.

C++ can be worse. I wanted to use the Boost Spirit library for CFG
parsing, and found that I couldn't read the compile errors I was
getting because 90% of the text was multiply nested template types. The C++
Standard Template Library uses templates so much to get close to Ruby's
flexibility, but the result is still more complicated than Ruby,
impossible to debug, and less flexible. At that point, why not go all the
way to a dynamically typed language?

--Ken Bloom

--
Ken Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...
I've added a signing subkey to my GPG key. Please update your keyring.

Martin Coxall

10/16/2006 1:42:00 PM

0

> C++ can be worse. I wanted to use the Boost Spirit library for CFG
> parsing, and found that I couldn't read the compile errors I was
> getting because 90% of the text was multiply nested template types. The C++
> Standard Template Library uses templates so much to get close to Ruby's
> flexibility, but the result is still more complicated than Ruby,
> impossible to debug, and less flexible. At that point, why not go all the
> way to a dynamically typed language?

Because then you're a different language with different use cases with
different benefits and drawbacks.

Boost is an incredibly good set of libraries, with an extremely high
level of QA. The great tragedy is that facilities like this were not
part of a C++ standard library a decade ago.

Still, the C++ Standards Committee are well aware of the problems that
templates cause with respect to indecipherable error messages, which
is why the new system of concepts has been proposed for C++0x, so the
compiler can flag straight away when you've tried to instantiate a
template parameter that won't work.

Also, if you're a genius, you can use template metaprogramming to do
some really spanky compile-time shenanigans.

Martin

Gavin Kistner

10/16/2006 2:01:00 PM

0

Avatar wrote:
> I would like to hear people's opinions on the ability to use variables
> without declaring them in dynamic languages like Ruby.

Could you clarify what you mean by that? Are you concerned about
methods like #instance_variable_set and #class_variable_set? Or more
generally about the fact that code like:

class Foo
@bar = 12
end

creates an instance variable on the fly at runtime, without requiring
some sort of
instance @bar
line that 'declares' it before use?

Martin Coxall

10/16/2006 2:12:00 PM

0

On 10/16/06, Avatar <acampbellb@hotmail.com> wrote:
> I would like to hear people's opinions on the ability to use variables
> without declaring them in dynamic languages like Ruby.

You mean without declaring their *type*, right?

It's more accurate to say simply that variables have no type in Ruby;
Rather the variable's contents have a type.

In any case, Ruby requires that variables be declared before use just
as any decent language worth the name does.

Martin

BIG Bird

9/14/2012 12:53:00 AM

0


"Gary" <not@none.com> wrote in message
news:a7t458hs75409ju5u858qqnftnl9vo4v1u@4ax.com...
: On Thu, 13 Sep 2012 17:50:19 -0400, "SNORDO" <Snordo@Teranews.com>
: wrote:
:
: >
: >"Gary" <not@none.com> wrote in message
: >news:nph458l82e80qa7128829alui485gtlmlk@4ax.com...
: >: Say What ?! Palin Tells Obama To "Grow A Big Stick" (DETAILS)
: >:
: >: http://globalgrind.com/news/sarah-palin-barack-obama-grow-big-sti...
: >:
: >
: >
: >Palin loves those big sticks, especially black ones,
: >
: >remember the basketball player, rice ???
: >
: >as a matter of fact 99% of hillbilly women prefer black men,
: > but looking at those lard assed,stupid ass, cross eyed, mouth breathin
: > white hillbilly men, you can understand why
:
: That was funny. According to Joe McGinniss' book, when she got
: back to the dormitory, she screamed to one of the girls :
:
: "I can't believe it ! I (blanked) a ( you know what) ! "
:
: I wonder if she told McCain about that ? I wonder if Ryan told
: Romney about his black sweetheart ?
:
:



I fucked a NIGGER!!!!! ???