Hi,

Yes, automatic semi. insertion is a feature - and a most horrible one!

I am unwilling to discuss it though: I must admit I completely and
uncritically submit to "higher authority" and Javascript-god Douglas
Crockford as far as code writing rules are concerned, since as far as
I'm concerned that guys simply is GOOD, or at least so much better
than ANY other voices I have heard so far (where Javascript is
concerned). I *highly* recommend the Crockford-videos on Yahoo's
developer theater for anyone writing Javascript. Okay, "uncritically"
is not quite right, to me his statements simply make sense. The only
exception I occasionally take is usage of the ++/-- operators,
although I limit myself to using them in the head of for-loops only.
When listening to Crockford one must not forget of course that his
advice is especially targeted at developers of mashup-able enterprise
large(r)-scale JS apps where *teams* rather than individuals have to
work with the code for a long time again and again, and not so much
for handfuls-of-lines-of-code for "beautifying" HTML pages.
However, since Rails is a framework IMHO those high and very strict
coding standards should apply to its JS code.

Yes, I'm willing to contribute and not just complain and I'll try to
do so - time permitting, which right now is a little scarce (I'm a
week behind schedule in a JS project and also just opened a restaurant
in Nuremberg, Germany, with an Italian cook/friend :-) ).

About redeclared variables:
1) see function handleMethod, variable field.
2) Further down in event handler document.on("submit",...) variable
"element" is declared twice.

Crockford gives a compelling case for putting all var-statements into
the TOP of the function instead of declaring them as they are used. I
forgot was the argument was, but it was very compelling. Crockford is
strong both in theory (computer science: programming languages) as
well as in practice. I may sound odd to freely admit I forgot the
argument and not to care, but I don't care - if you listen to the
Crockford videos you'll understand :-)  Seriously, I'm not nearly as
good as this guy and since his videos are publicly available why
should I try to repeat his statements, which is all I can do?

Thanks for the github pointers to the prototype and jquery components,
I wasn't aware of them but only of the code bundled with rails
directly. Contributing to the Guides is on my TODO list... I wasn't so
much calling for other people's action but was/am much more interested
in finding background info - such as those github links. One usually
assumes much more intention than there is when one doesn't know all
the things that are NOT going on ;-)

Michael



On Jul 2, 1:31 pm, Rodrigo Rosenfeld Rosas <[email protected]> wrote:
> Michael, please take a look at ECMAScript specification, section 7.9 -
> "Automatic Semicolon Insertion":
>
> http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262...
>
> This is not an error but a feature. The only case where this could lead
> to some problem is code like this:
>
> var l = variable.length
> (function(){alert('a')})()
>
> In this case, if we miss the semicolon, this would be interpreted as:
>
> var l = variable.length(function(){alert('a')})()
>
> You get the point. But this is only to mention that it is ok to not put
> the semicolons at the end of the line. I barely put them when writing
> Javascript...
>
> About repeated variable names, I didn't find any case. Could you point
> me one? Remember that you can define the same variable multiple times in
> different scopes, such as functions. This is no problem.
>
> But I'll take the chance to discuss another issue I've just opened
> yesterday on Github:
>
> http://github.com/rails/jquery-ujs/issues#issue/11
>
> It would be great if the jQuery driver supported including the CSRF
> token in all AJAX post calls, such as "$.load(url, {data: sample})".
>
> What do you think?
>
> Rodrigo.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to