Axel Rauschmayer wrote:
- Implicit conversions are messy (and a superset of pitfall #2), but
seem to surprise people much less than the above items.
I think you have it backwards.
My experience, so far. I’d be interested in other examples of implicit
conversions stumping people.
What stumped who, when? Any bugs/github issues/blog posts to cite?
if (!p) { /* p is null or 0 in C */ }
is common in C-like languages that tolerate it. JS does, with a
Perl/AWK/etc. addition: "" is falsy, as well as 0, null, undefined, and
false.
I've never heard anyone doing real work complain, and the Object
Detection pattern on the web relies on undefined => false along with
missing property read resulting in undefined.
- Modules close another important hole in JavaScript, but I wouldn’t
consider that hole a pitfall.
You mean free variables being static errors? That is not a done deal yet.
No, I meant the hole of not having a module system that is part of the
language. They don’t plug, they *are* the plug. ;-)
Sorry for being ambiguous.
But what's the pitfall? "Lack of a module system" describes a solution
more than a symptom.
Missing properties yielding undefined still burns many JS
programmers. Not an implicit conversion, so worth a separate item.
In chains? obj.prop1.prop2?
No, that throws promptly with near-enough blame!
The problem is the dual of object detection as a useful pattern. When
you expect var foo = obj.foo to get an extant property's value, and let
foo flow off into complex control flows before being dereferenced, then
you have the "come-from" problem.
/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss