I stand corrected. Although Smalltalk solves it by introducing a special method call syntax (which is perfectly fine). I was mostly thinking about C-style-method-call-syntax when I wrote this (Perl, Python, JS).
> They do, if you define a variable within the block it'll be local to the block. Ruby 1.9 even allowed shadowing variables from the parent method (which isn't possible in 1.8)
I did mention explicitly that I wasn't talking about variable scope, so yeah, we're both correct :)
Meh. Smalltalk comes from a time when not all languages had to be ALGOL-style, so it just has its own syntax.
> I was mostly thinking about C-style-method-call-syntax when I wrote this (Perl, Python, JS).
That is no issue, if you have first-class blocks. At most you'll have commas between your blocks because they'll be arguments like every other. Here's a python-ish version using chevrons for blocks:
error = (request.form['username'] != app.config['USERNAME']).then(⟨
"Invalid Username"
⟩, else=⟨
None
⟩)
Except when they don't, but if you can't build multi-block methods (or methods on blocks) because it looks like shit, you don't think about them. It's a form of blub, nothing more. There are numerous multi-block methods, Ruby's syntactic limitations just makes them unwieldy and thus avoided. Just as Python's or Java's syntactic limitations make higher-order methods unwieldy and thus avoided.
> By having custom syntax for "method that takes a single block" you get a certain simplicity that makes methods look like built-in keywords
Smalltalk stands in stark disproval of this assertion.
> It does make multi-block methods look ugly, but frankly, I think they look ugly in any language.
Eh?
I don't think that looks ugly.> Compared to JavaScript/Perl/Python-lambas, Ruby's blocks don't introduce another scope.
They do, if you define a variable within the block it'll be local to the block. Ruby 1.9 even allowed shadowing variables from the parent method (which isn't possible in 1.8)
> "self" [...] still refer to the method's scope
So does it with the vast majority of languages. Certainly does in Python. Javascript behaves strangely with its somewhat-dynamically-scoped-but-not-really `this` but it's a peculiarity of JS, not Ruby.
> and "return" still refer to the method's scope (I'm not sure what this type of scope is called)
It's a non-local return, not really a scope.