Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

jslint_com · This group has moved to Google Plus.

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 584
  • Category: JavaScript
  • Founded: Mar 7, 2008
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Messages

Advanced
Messages Help
scope bug? catch (e) "e already defined"   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages Sort by Date  
#77 From: "wleingang" <wleingang@...>
Date: Mon Jun 16, 2008 4:15 pm
Subject: scope bug? catch (e) "e already defined"
wleingang
Send Email Send Email
 
Hi. Has anyone run into this before?

try {
this.var1 = "test";
}catch (e) {}

try {
this.var2 = "test";
}catch (e) {}


On the second catch, JSLint thinks that e is already defined... even
though from that scope there is no way it is already defined. Unless I
don't understand this should be valid code right?

Thanks.
Will




#78 From: Thomas Koch <thomas@...>
Date: Mon Jun 16, 2008 4:44 pm
Subject: Re: [jslint] scope bug? catch (e) "e already defined"
cluj_de
Send Email Send Email
 
Am Montag 16 Juni 2008 18:15:52 schrieb wleingang:
> Hi. Has anyone run into this before?
>
> try {
> this.var1 = "test";
> }catch (e) {}
>
> try {
> this.var2 = "test";
> }catch (e) {}
>
>
> On the second catch, JSLint thinks that e is already defined... even
> though from that scope there is no way it is already defined. Unless I
> don't understand this should be valid code right?
>
> Thanks.
> Will

Hi Will,

I've another issue with already defined, which even appears in yui:

if (typeof YAHOO == "undefined" || !YAHOO) {
/**
* The YAHOO global namespace object. If YAHOO is already defined, the
* existing YAHOO object will not be overwritten so that defined
* namespaces are preserved.
* @class YAHOO
* @static
*/
var YAHOO = {};
}

taken from yuiloader-beta.js, line 64.

It would be nice, if I could use this pattern without having Jslint
complaining.


Best regards,
--
Thomas Koch, Software Developer
http://www.koch.ro

Young Media Concepts GmbH
Sonnenstr. 4
CH-8280 Kreuzlingen
Switzerland

Tel +41 (0)71 / 508 24 86
Fax +41 (0)71 / 560 53 89
Mobile +49 (0)170 / 753 89 16
Web www.ymc.ch



#79 From: "wleingang" <wleingang@...>
Date: Mon Jun 16, 2008 5:15 pm
Subject: Re: [jslint] scope bug? catch (e) "e already defined"
wleingang
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, Thomas Koch <thomas@...> wrote:
> I've another issue with already defined, which even appears in yui:
>
> if (typeof YAHOO == "undefined" || !YAHOO) {
> /**
> * The YAHOO global namespace object. If YAHOO is already
defined, the
> * existing YAHOO object will not be overwritten so that defined
> * namespaces are preserved.
> * @class YAHOO
> * @static
> */
> var YAHOO = {};
> }
>
> taken from yuiloader-beta.js, line 64.
>
> It would be nice, if I could use this pattern without having Jslint
> complaining.

I had the same problem. I ended up replacing those namespace
declarations in each individual file with /*global YAHOO*/

I agree that if you are checking for its existance before defining
it, then it shouldn't complain... but I am not sure where a syntax
checker leaves off and a compiler takes over.

Will




#80 From: "Douglas Crockford" <douglas@...>
Date: Mon Jun 16, 2008 5:20 pm
Subject: Re: scope bug? catch (e) "e already defined"
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "wleingang" <wleingang@...> wrote:
>
> Hi. Has anyone run into this before?
>
> try {
> this.var1 = "test";
> }catch (e) {}
>
> try {
> this.var2 = "test";
> }catch (e) {}
>
>
> On the second catch, JSLint thinks that e is already defined... even
> though from that scope there is no way it is already defined. Unless I
> don't understand this should be valid code right?

There are scope definition problems with respect to catch in some
browsers. I recommend that you give each catch its own name (e1, e2)
to be safe.




#81 From: "Re Miya" <remiya_ws@...>
Date: Mon Jun 16, 2008 6:30 pm
Subject: Re: scope bug? catch (e) "e already defined"
remiya_ws
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
wrote:
>
> --- In jslint_com@yahoogroups.com, "wleingang" <wleingang@> wrote:
> >
> > Hi. Has anyone run into this before?
> >
> > try {
> > this.var1 = "test";
> > }catch (e) {}
> >
> > try {
> > this.var2 = "test";
> > }catch (e) {}
> >
> >
> > On the second catch, JSLint thinks that e is already defined... even
> > though from that scope there is no way it is already defined.
Unless I
> > don't understand this should be valid code right?
>
> There are scope definition problems with respect to catch in some
> browsers. I recommend that you give each catch its own name (e1, e2)
> to be safe.
>
This is what I have done. Use different names for the events.

However I have stuck into another problem:

var test = function(){
this.pub_function = function(){
pvt_fn();
}
var pvt_fn = function(){
// Code here
}
}

JsLint reports pvt_fn as a global reference. Is this normal?




#82 From: "Douglas Crockford" <douglas@...>
Date: Mon Jun 16, 2008 6:42 pm
Subject: Re: scope bug? catch (e) "e already defined"
douglascrock...
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "Re Miya" <remiya_ws@...> wrote:
> However I have stuck into another problem:
>
> var test = function(){
> this.pub_function = function(){
> pvt_fn();
> }
> var pvt_fn = function(){
> // Code here
> }
> }
>
> JsLint reports pvt_fn as a global reference. Is this normal?

Move the definition of pvt_fn before the pub_function that uses it.




#83 From: "Re Miya" <remiya_ws@...>
Date: Mon Jun 16, 2008 6:55 pm
Subject: Re: scope bug? catch (e) "e already defined"
remiya_ws
Send Email Send Email
 
--- In jslint_com@yahoogroups.com, "Douglas Crockford" <douglas@...>
wrote:
>
> --- In jslint_com@yahoogroups.com, "Re Miya" <remiya_ws@> wrote:
> > However I have stuck into another problem:
> >
> > var test = function(){
> > this.pub_function = function(){
> > pvt_fn();
> > }
> > var pvt_fn = function(){
> > // Code here
> > }
> > }
> >
> > JsLint reports pvt_fn as a global reference. Is this normal?
>
> Move the definition of pvt_fn before the pub_function that uses it.
>
That really makes sense.
Up to now I have been putting the private fns at the end like this
var test = function(){
this.pub_function = function(){
pvt_fn();
}
//------------ PRIVATE METHODS -----------//
var pvt_fn = function(){
// Code here
}
}
Now I will put them at the top

var test = function(){
//------------ PRIVATE METHODS -----------//
var pvt_fn = function(){
// Code here
}

//------------ PUBLIC METHODS -----------//
this.pub_function = function(){
pvt_fn();
}
}

Thank you!





 
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help