BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

unused variables come up in grey but I can see it being used

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE
View previous topic :: View next topic  
Author Message
Flip
Guest





PostPosted: Thu Aug 19, 2004 2:44 pm    Post subject: unused variables come up in grey but I can see it being used Reply with quote



How come an instance variable comes up in grey at the top of my class, but I
can see it being used/referenced/set with a variable in an overloaded
constructor? Nope, it's not being shadowed at all (double, triple,
quadruple checked that one).

Anyone else seen this behaviour? What rules does JB use to decide if the
var is used or not? Thanks.


Back to top
Gillmer J. Derge [TeamB]
Guest





PostPosted: Thu Aug 19, 2004 3:35 pm    Post subject: Re: unused variables come up in grey but I can see it being Reply with quote



Flip wrote:
Quote:
Anyone else seen this behaviour? What rules does JB use to decide if the
var is used or not? Thanks.

I'm not sure, but I think use in a constructor doesn't count. That kind
of makes sense. Consider the following example:

public class Foo {
private int i;
public Foo() {
i = 0;
}
}

Do we really need "i" for anything?

--
Gillmer J. Derge [TeamB]

Back to top
Gillmer J. Derge [TeamB]
Guest





PostPosted: Thu Aug 19, 2004 3:56 pm    Post subject: Re: unused variables come up in grey but I can see it being Reply with quote



Flip wrote:
Quote:
Anyone else seen this behaviour? What rules does JB use to decide if the
var is used or not? Thanks.

I thought about this some more. If you use JBuilder's "Find References"
feature, you'll see that it makes a distinction between a read reference
and a write reference. I suspect that only reads count as "use" for the
sake of whether a private variable turns gray.

--
Gillmer J. Derge [TeamB]

Back to top
Flip
Guest





PostPosted: Thu Aug 19, 2004 7:17 pm    Post subject: Re: unused variables come up in grey but I can see it being Reply with quote

Quote:
feature, you'll see that it makes a distinction between a read reference
I have been thinking about it like that too. By read reference, do you mean

by using it on the RHS of the equation sign? I guess it makes sense if you
assign it a value (using it on the LHS), but never on the RHS, it's still
unused.

That makes sense (the read reference). Thanks! :>



Back to top
Gillmer J. Derge [TeamB]
Guest





PostPosted: Thu Aug 19, 2004 7:44 pm    Post subject: Re: unused variables come up in grey but I can see it being Reply with quote

Flip wrote:
Quote:
By read reference, do you mean
by using it on the RHS of the equation sign?

That's probably the most common case, but there are others. For
example, passing the value as a function argument is a read.

System.out.println(x); // reads x

"i++" is both a read and a write (though if JBuilder is smart enough it
might ignore the read when the result is unused such as the common use
of i++ in a for loop). Basically anything that uses the current value
for something is a read.

--
Gillmer J. Derge [TeamB]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> JBuilder IDE All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.