You should probably assign an object to the underscore, otherwise any argument which is undefined will match: js> var _ js> _ == undefined true Just doing "var _ = {}" should be sufficient. edit: however, this conflicts with Underscore.js ( http://documentcloud.github.com/underscore/ ), but if you put an "if (typeof _ === "undefined")" around the assignment you should be ok
It also conflicts with gettext libraries. The name '_' should be considered reserved for that purpose.
Wherein Javascript borrows a language feature from Arc
11–20 of 22 posts
Re: Wherein Javascript borrows a language feature from Arc
#12You should probably assign an object to the underscore, otherwise any argument which is undefined will match: js> var _ js> _ == undefined true Just doing "var _ = {}" should be sufficient. edit: however, this conflicts with Underscore.js ( http://documentcloud.github.com/underscore/ ), but if you put an "if (typeof _ === "undefined")" around the assignment you should be ok
It also conflicts with gettext libraries. The name '_' should be considered reserved for that purpose.
Re: Wherein Javascript borrows a language feature from Arc
#13> geolocator.getLatLng("Forest Park, St. Louis, MO", function(center) { > displayMapAt(center, 14); > }); To my eyes, that solution is just fine. I don't think I'll ever be swayed to believe that adding on layers of indirection to JavaScript code for the sake of "syntactic goodness" is rationally motivated by leading to more practical power for actually solving problems.
Agreed. If you're writing something in a web browser, use sane JavaScript. Every time I have done something "fancy" with a language, there has been a large hidden cost later on, be that complicated debugging sessions, new hire training, or unintended side effects. Terrible syntax/rewriting hacks in Rails are probably what convinced me that I do not like ruby. If you truly care about programmer efficiency, you probabl…
Re: Wherein Javascript borrows a language feature from Arc
#14> geolocator.getLatLng("Forest Park, St. Louis, MO", function(center) { > displayMapAt(center, 14); > }); To my eyes, that solution is just fine. I don't think I'll ever be swayed to believe that adding on layers of indirection to JavaScript code for the sake of "syntactic goodness" is rationally motivated by leading to more practical power for actually solving problems.
Agreed. If you're writing something in a web browser, use sane JavaScript. Every time I have done something "fancy" with a language, there has been a large hidden cost later on, be that complicated debugging sessions, new hire training, or unintended side effects. Terrible syntax/rewriting hacks in Rails are probably what convinced me that I do not like ruby. If you truly care about programmer efficiency, you probabl…
All software should be as complex as it needs to be to do the job, and no more so (where complex means the cognitive load necessary to understand it). Unfortunately 99% of programmers and 100% of programmers' managers don't understand this (both numbers are probably correct to the nearest integer, in my experience).
Re: Wherein Javascript borrows a language feature from Arc
#15Clojure has #(+ % 10) for Arc's [+ _ 10]. Does anyone know if Arc inspired Clojure, or whether there's prior art for this syntax?
Re: Wherein Javascript borrows a language feature from Arc
#16Clojure has #(+ % 10) for Arc's [+ _ 10]. Does anyone know if Arc inspired Clojure, or whether there's prior art for this syntax?
Re: Wherein Javascript borrows a language feature from Arc
#17 geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt);
Is better than this? displayMapAt(geolocator.getLatLng("Forest Park, St. Louis, MO"));
That is, why is it more sensible for getLatLng to accept a callback function that will accept its result, when one can just pass its result to a function?Re: Wherein Javascript borrows a language feature from Arc
#18Can someone explain why this: geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt); Is better than this? displayMapAt(geolocator.getLatLng("Forest Park, St. Louis, MO")); That is, why is it more sensible for getLatLng to accept a callback function that will accept its result, when one can just pass its result to a function?
Another way to do this sort of thing, that might feel more composable: have geolocator.getLatLng() return a 'promise' object that will be asynchronously resolved.
Re: Wherein Javascript borrows a language feature from Arc
#19Can someone explain why this: geolocator.getLatLng("Forest Park, St. Louis, MO", displayMapAt); Is better than this? displayMapAt(geolocator.getLatLng("Forest Park, St. Louis, MO")); That is, why is it more sensible for getLatLng to accept a callback function that will accept its result, when one can just pass its result to a function?
Re: Wherein Javascript borrows a language feature from Arc
#20Clojure has #(+ % 10) for Arc's [+ _ 10]. Does anyone know if Arc inspired Clojure, or whether there's prior art for this syntax?