View Single Post
  #2   Spotlight this post!  
Unread 14-06-2010, 23:02
timothyb89 timothyb89 is offline
code monkey
FRC #1977 (Loveland High Robotics)
Team Role: Alumni
 
Join Date: Oct 2008
Rookie Year: 2009
Location: Loveland, Colorado
Posts: 45
timothyb89 will become famous soon enough
Re: Non Strict Variables

By design, Java doesn't really support untyped/non-strict variables. The closest you can come with "plain old Java" is something like this:
Code:
Object aString = "Hello, world.";
System.out.println(((String) aString).toUpperCase());
'Object' works fine as a generic container, but you'll have to typecast before calling any functions.

If you're writing for the cRIO that's probably about all you can do without any extra libraries due to the lack of reflection support. But for desktop Java (version 1.5 and up) you can pretty happily use Groovy, Jython, or any of the other languages that run natively on the JVM (JavaScript, BeanShell, JRuby, etc).

For the cRIO, though, you could likely use an old version of Groovy (or any other sufficiently old JVM-based scripting language) to build for JDK1.3. Languages this old are precompiled into standard bytecode and shouldn't have problems running on older versions of the JVM.

Even so, there might be a better way to accomplish things than with untyped variables, depending on what you're trying to do.
__________________
FRC-DB: A detailed, web-based scouting database for FRC teams with lots of interesting statistics.
Reply With Quote