For what it's worth, I'm a *huge* fan of Ruby's {|-style blocks.
Also, it's worth noting that "do...done" seems to be a bit more
popular in Ruby programs that I've seen.

I'm not a fan of the fact that these blocks have different behavior
than "regular" functions and methods, but that's a qualm for a
different mailing list, and I'm not a rubyist anyhow :)

Consider this: w = (x)->y || z

That code is not obvious at all.  Which of these would it be?

1: w = function (x) { return y } || z
2: w = function (x) { return y || z }

It seems to me that there must be some sort of delineation around the
function start and end.  I agree that "function ... return" is way too
many characters to write and read for such a fundamental bit of
syntax.

This style is quite clear and readable:

w = {|x| y || z}
w = {|x| y} || z

However, that's pretty awful to type.  Perhaps even worse than ->.
Maybe {(x) y || z} might be better?  Of course, that would break
blocks that start with parenthesized sequence blocks, but is that
really a concern?  Blocks in JS are useless, can't we just do away
with them?

On Sat, May 7, 2011 at 10:04, Peter Michaux <petermich...@gmail.com> wrote:
> On Sat, May 7, 2011 at 9:56 AM, Thaddee Tyl <thaddee....@gmail.com> wrote:
>
>> JavaScript is still seen as a badly object-oriented programming
>> language by those who still think it is java with a weird syntax.
>
> I think that concpetion has declined a lot as rich clients have forced
> people to become better acquainted with JavaScript and a lot more has
> been written on the language.
>
>> I do
>> hope it grows to be known as an outstanding functional programming
>> language.
>
> JavaScript won't ever be known as a outstanding functional programming
> language until it has proper tail calls. This would give the language
> new capabilities it doesn't have now.
>
> Peter
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to