We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Please explain this unexpected syntax

Medium Priority
373 Views
Last Modified: 2013-12-10
I have encountered some TCL code (well, Jacl code really), that has the statements shown below.

I understand that #1 creates a new java Object, having a value of 1.  So far, so good.

What I don't understand is the 2nd statement.  I'm used to seeing

set variableName value

So what is this doing?

set 0 value

and why is this after a dereferenced variable?

If you could explain this, and provide equivalent Jython, it would be greatly appreciated.

Thanks
set params [java::new {java.lang.Object[]} {1}]
$params set 0 [java::field com.ibm.websphere.scheduler.BeanTaskInfo class]

Open in new window

Comment
Watch Question

HonorGodSoftware Engineer
CERTIFIED EXPERT

Author

Commented:
Here's the "equivalent" Jython code...


import com.ibm.websphere.scheduler as sch
 
params = [ sch.BeanTaskInfo ];    # class reference
sigs   = [ 'java.lang.Class' ];   # "Signature" identifying "params" type

Open in new window

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
its setting an element in the array isn't it

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
HonorGodSoftware Engineer
CERTIFIED EXPERT

Author

Commented:
According to the Tcl documentation, one would use the "array" keyword to define an array.

So, I'm still confused.
array set colorcount {
    red   1
    green 5
    blue  4
    white 9
}

Open in new window

Commented:
It'a special JACL syntax to manipulate Java arrays:

From http://tcljava.sourceforge.net/docs/TclJava/JavaNewCmd.html:

In this example, we see how to allocate an array of java.lang.String objects. This example also demonstrates Java array object commands and their equivalent Java statements, see the javaArrayObj section for more information.
# This is equivalent to the Java statement.
# String[] arr = new String[2];
set arr [java::new {String[]} {2}]

# Set the values of the array elements.
# This is equivalent to the following Java statements.
# arr[0] = "Hello";
# arr[1] = "World";
$arr set 0 "Hello"
$arr set 1 "World"
HonorGodSoftware Engineer
CERTIFIED EXPERT

Author

Commented:
mish33 was completely correct, so gets most of the points.
objects was first, and partially correct, so get some of the points.

Thanks again folks!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.