Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion goog.array.map(undefined, handler): the worst from both worlds
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Erik Arvidsson  
View profile  
 More options May 16 2010, 1:42 pm
From: Erik Arvidsson <erik.arvids...@gmail.com>
Date: Sun, 16 May 2010 10:42:45 -0700
Local: Sun, May 16 2010 1:42 pm
Subject: Re: goog.array.map(undefined, handler): the worst from both worlds

I'm sorry. I did understand what you wrote but I was not really replying to
it.

Calling goog.array.map with undefined is wrong. I agree that it is confusing
that it iterates over the window. Adding runtime checks for invalid usage is
something we have policy against. It adds to the code size as well as to the
runtime cost.

On May 16, 2010 3:26 AM, "artemy tregubenko" <m...@arty.name> wrote:

Thank you for your reply, but it looks like I've failed to explain my
problem.

The following example is quite close to the real code I have. I do not
call goog.array.map(window, fun). I do not call
goog.array.map(undefined, fun).  I have an object `foo`, containing
array as its property `bar`. My code iterates over this array:
goog.array.map(foo.bar, fun). Sometimes object doesn't have that
property `bar`, like object `baz` here. Since there's no array and
there're no elements of array, I expect code not to do anything.
However code calls `foo(window)`. This is the problem.

var foo = {bar: []}, baz = {};
var f = function(param){ console.log(param) };
goog.array.map(foo.ba...
This problem appears at runtime  and thus cannot be solved by
compiler. I propose to replace

return goog.array.ARRAY_PROTOTYPE_.map.call(arr, f, opt_obj);
with

   return !arr ? [] : goog.array.ARRAY_PROTOTYPE_.map.call(arr, f,
opt_obj);

On May 16, 11:09 am, Erik Arvidsson <erik.arvids...@gmail.com> wrote:

> Calling goog.array.map(win...
> On Fri, May 14, 2010 at 04:37, artemy tregubenko <m...@arty.name> wrote:
> > Hello,

> > I've jus...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.