[brailleblaster] Re: [brailleblaster.newdesign] push by john.bo...@xxxxxxxxxxxxxxxxx - work on Styles class on 2013-01-15 12:41 GMT

  • From: Michael Whapples <mwhapples@xxxxxxx>
  • To: brailleblaster@xxxxxxxxxxxxx
  • Date: Thu, 17 Jan 2013 21:30:25 +0000

Here are a few thoughts on how you can determine the solution, it mainly comes down to how does the calling line of code know which instance its dealing with? Some possible answers are:

1. Are you creating a new instance?
2. Have you been handed an instance from somewhere else?
3. Are you accessing an existing instance from a variable?
4. Is the method you are calling fom really meant to be static (normally only relevant when dealing with a method on the same class)?

Just going by the name startStyle, I suspect its option one, you need to create a new instance within the startStyle method, however don't take my word here as I am only going by the name of the method and not actually knowing what the method does.

Michael Whapples
On 17/01/2013 19:55, John J. Boyer wrote:
Good question. In the startStyle method in the Styles class I was
getting a compile error of "reference to nonstatic variable from static
contgext." So I made semanticsTable static and introduced the
getSemanticEntry method. semanticsTable really should not be static, as
you say. How can I get around this?

Thanks,
John

On Thu, Jan 17, 2013 at 06:34:43PM +0000, Michael Whapples wrote:
Sorry for not getting back on this earlier, but I don't understand why
some of this change happend.

-SemanticEntry[] semanticsTable = new SemanticEntry[100];
+static SemanticEntry[] semanticsTable = new SemanticEntry[100];

So why is semanticsTable static? I would have thought it was a prime
example of an instance variable, the table is only relevant for that
instance, which according to an earlier comment is for a given document.
Why should the table of semantic actions be common to all instances, and
so if I understand the earlier comment will be shared for all documents?

Michael Whapples


Other related posts: