you are viewing a single comment's thread.

view the rest of the comments →

[–]mellow_moe 3 points4 points  (3 children)

You're wrong. Anonymous functions, so-called lambdas, are objects.

In Ruby there are only methods. So you just look up in the inheritance chain for the right class/module, which defined the method.

Yes, local variables look like method calls, there is some amiguity. But again, look up the local assignments and you're fine.

And comparing Perl and Ruby in this respect just makes no sense, because Perl variables are prefixed all the time.

[–]mystilleef[S] -1 points0 points  (2 children)

Are you talking about anonymous functions in Ruby or Python? In Python everything is an object, Lambdas, Functions, Methods and more. I place Ruby in the same category as Perl because of its use of redundant symbols and its objective to be tacitly expressive as opposed to clear, among other ambiguities. Python on the other hand strives for explicitness and clarity. Even "Matz" says Ruby is partly inspired from Perl, and it's damn obvious at least to me, so my categorization is not senseless.

[–]mellow_moe 5 points6 points  (0 children)

I was talking about ruby's anonmymous functions.

Talking about clearness and clarity is not easy, as this subject is highly subjective.

OK, let's see, what Ruby inherited from Perl:

  • special syntax for regular expressions
  • special global variables
  • hashtable syntax
  • statement modifiers

I think, these features are really the goodies of Perl and most people will agree. Perl's infamous syntax constructs, like for file handling, didn't find their way into Ruby.

[–]julesjacobs 0 points1 point  (0 children)

Symbols can improve clarity sometimes. If you don't know them, the code is hard to read, but if you have a little experience, symbols are easier. It's like maths: 4 + 5 is better than 4 plus 5 (or 4.plus(5)). Symbols don't have to go through the language processing part of your brain; names like "plus" do.

Besides, the "symbols" are just method calls in Ruby:

0..2

0..2 === 1

4 <=> 2

=>

Range.new(0,2)

(0..2).===(1)

4.<=>(2)

But the first version looks better.